
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Implementation-specific definitions &#8212; psa_crypto_api 1.0 beta3 documentation</title>
    <link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript" id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/underscore.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <script type="text/javascript" src="_static/language_data.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="prev" title="Introduction" href="general.html" />
   
  <link rel="stylesheet" href="_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <div class="section" id="implementation-specific-definitions">
<h1>Implementation-specific definitions</h1>
<div class="section" id="psa_key_handle_t">
<span id="c.psa_key_handle_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_handle_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="n">_unsigned_integral_type_</span> <span class="n">psa_key_handle_t</span><span class="p">;</span>
</pre></div>
</div>
<p>Key handle.</p>
<p>This type represents open handles to keys. It must be an unsigned integral type. The choice of type is implementation-dependent.</p>
<p>0 is not a valid key handle. How other handle values are assigned is implementation-dependent.</p>
</div>
</div>
<div class="section" id="library-initialization">
<h1>Library initialization</h1>
<div class="section" id="psa_crypto_init">
<span id="c.psa_crypto_init"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_crypto_init</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_crypto_init</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Library initialization.</p>
<p>Applications must call this function before calling any other function in this module.</p>
<p>Applications may call this function more than once. Once a call succeeds, subsequent calls are guaranteed to succeed.</p>
<p>If the application calls other functions before calling <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>, the behavior is undefined. Implementations are encouraged to either perform the operation as if the library had been initialized or to return <a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a> or some other applicable error. In particular, implementations should not return a success status if the lack of initialization may have security implications, for example due to improper seeding of the random number generator.</p>
</div>
</div>
<div class="section" id="key-attributes">
<h1>Key attributes</h1>
<div class="section" id="psa_key_attributes_t">
<span id="c.psa_key_attributes_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_attributes_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">psa_key_attributes_s</span> <span class="n">psa_key_attributes_t</span><span class="p">;</span>
</pre></div>
</div>
<p>The type of a structure containing key attributes.</p>
<p>This is an opaque structure that can represent the metadata of a key object. Metadata that can be stored in attributes includes:</p>
<ul class="simple">
<li>The location of the key in storage, indicated by its key identifier and its lifetime.</li>
<li>The key’s policy, comprising usage flags and a specification of the permitted algorithm(s).</li>
<li>Information about the key itself: the key type and its size.</li>
<li>Implementations may define additional attributes.</li>
</ul>
<p>The actual key material is not considered an attribute of a key. Key attributes do not contain information that is generally considered highly confidential.</p>
<p>An attribute structure can be a simple data structure where each function <code class="docutils literal notranslate"><span class="pre">psa_set_key_xxx</span></code> sets a field and the corresponding function <code class="docutils literal notranslate"><span class="pre">psa_get_key_xxx</span></code> retrieves the value of the corresponding field. However, implementations may report values that are equivalent to the original one, but have a different encoding. For example, an implementation may use a more compact representation for types where many bit-patterns are invalid or not supported, and store all values that it does not support as a special marker value. In such an implementation, after setting an invalid value, the corresponding get function returns an invalid value which may not be the one that was originally stored.</p>
<p>An attribute structure may contain references to auxiliary resources, for example pointers to allocated memory or indirect references to pre-calculated values. In order to free such resources, the application must call <a class="reference internal" href="#c.psa_reset_key_attributes" title="psa_reset_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_reset_key_attributes()</span></code></a>. As an exception, calling <a class="reference internal" href="#c.psa_reset_key_attributes" title="psa_reset_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_reset_key_attributes()</span></code></a> on an attribute structure is optional if the structure has only been modified by the following functions since it was initialized or last reset with <a class="reference internal" href="#c.psa_reset_key_attributes" title="psa_reset_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_reset_key_attributes()</span></code></a>:</p>
<ul class="simple">
<li><a class="reference internal" href="#c.psa_set_key_id" title="psa_set_key_id"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_id()</span></code></a></li>
<li><a class="reference internal" href="#c.psa_set_key_lifetime" title="psa_set_key_lifetime"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_lifetime()</span></code></a></li>
<li><a class="reference internal" href="#c.psa_set_key_type" title="psa_set_key_type"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_type()</span></code></a></li>
<li><a class="reference internal" href="#c.psa_set_key_bits" title="psa_set_key_bits"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_bits()</span></code></a></li>
<li><a class="reference internal" href="#c.psa_set_key_usage_flags" title="psa_set_key_usage_flags"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_usage_flags()</span></code></a></li>
<li><a class="reference internal" href="#c.psa_set_key_algorithm" title="psa_set_key_algorithm"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_algorithm()</span></code></a></li>
</ul>
<p>Before calling any function on a key attribute structure, the application must initialize it by any of the following means:</p>
<ul>
<li><p class="first">Set the structure to all-bits-zero, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_attributes_t</span> <span class="n">attributes</span><span class="p">;</span>
<span class="n">memset</span><span class="p">(</span><span class="o">&amp;</span><span class="n">attributes</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">attributes</span><span class="p">));</span>
</pre></div>
</div>
</li>
<li><p class="first">Initialize the structure to logical zero values, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_attributes_t</span> <span class="n">attributes</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">};</span>
</pre></div>
</div>
</li>
<li><p class="first">Initialize the structure to the initializer <a class="reference internal" href="#c.PSA_KEY_ATTRIBUTES_INIT" title="PSA_KEY_ATTRIBUTES_INIT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_ATTRIBUTES_INIT</span></code></a>, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_attributes_t</span> <span class="n">attributes</span> <span class="o">=</span> <span class="n">PSA_KEY_ATTRIBUTES_INIT</span><span class="p">;</span>
</pre></div>
</div>
</li>
<li><p class="first">Assign the result of the function <a class="reference internal" href="#c.psa_key_attributes_init" title="psa_key_attributes_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_attributes_init()</span></code></a> to the structure, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_attributes_t</span> <span class="n">attributes</span><span class="p">;</span>
<span class="n">attributes</span> <span class="o">=</span> <span class="n">psa_key_attributes_init</span><span class="p">();</span>
</pre></div>
</div>
</li>
</ul>
<p>A freshly initialized attribute structure contains the following values:</p>
<ul class="simple">
<li>lifetime: <a class="reference internal" href="#c.PSA_KEY_LIFETIME_VOLATILE" title="PSA_KEY_LIFETIME_VOLATILE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code></a>.</li>
<li>key identifier: unspecified.</li>
<li>type: <code class="docutils literal notranslate"><span class="pre">0</span></code>.</li>
<li>key size: <code class="docutils literal notranslate"><span class="pre">0</span></code>.</li>
<li>usage flags: <code class="docutils literal notranslate"><span class="pre">0</span></code>.</li>
<li>algorithm: <code class="docutils literal notranslate"><span class="pre">0</span></code>.</li>
</ul>
<p>A typical sequence to create a key is as follows:</p>
<ol class="arabic simple">
<li>Create and initialize an attribute structure.</li>
<li>If the key is persistent, call <a class="reference internal" href="#c.psa_set_key_id" title="psa_set_key_id"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_id()</span></code></a>. Also call <a class="reference internal" href="#c.psa_set_key_lifetime" title="psa_set_key_lifetime"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_lifetime()</span></code></a> to place the key in a non-default location.</li>
<li>Set the key policy with <a class="reference internal" href="#c.psa_set_key_usage_flags" title="psa_set_key_usage_flags"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_usage_flags()</span></code></a> and <a class="reference internal" href="#c.psa_set_key_algorithm" title="psa_set_key_algorithm"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_algorithm()</span></code></a>.</li>
<li>Set the key type with <a class="reference internal" href="#c.psa_set_key_type" title="psa_set_key_type"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_type()</span></code></a>. Skip this step if copying an existing key with <a class="reference internal" href="#c.psa_copy_key" title="psa_copy_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_copy_key()</span></code></a>.</li>
<li>When generating a random key with <a class="reference internal" href="#c.psa_generate_key" title="psa_generate_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_generate_key()</span></code></a> or deriving a key with <a class="reference internal" href="#c.psa_key_derivation_output_key" title="psa_key_derivation_output_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_output_key()</span></code></a>, set the desired key size with <a class="reference internal" href="#c.psa_set_key_bits" title="psa_set_key_bits"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_bits()</span></code></a>.</li>
<li>Call a key creation function: <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a>, <a class="reference internal" href="#c.psa_generate_key" title="psa_generate_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_generate_key()</span></code></a>, <a class="reference internal" href="#c.psa_key_derivation_output_key" title="psa_key_derivation_output_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_output_key()</span></code></a> or <a class="reference internal" href="#c.psa_copy_key" title="psa_copy_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_copy_key()</span></code></a>. This function reads the attribute structure, creates a key with these attributes, and outputs a handle to the newly created key.</li>
<li>The attribute structure is now no longer necessary. You may call <a class="reference internal" href="#c.psa_reset_key_attributes" title="psa_reset_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_reset_key_attributes()</span></code></a>, although this is optional with the workflow presented here because the attributes currently defined in this specification do not require any additional resources beyond the structure itself.</li>
</ol>
<p>A typical sequence to query a key’s attributes is as follows:</p>
<ol class="arabic simple">
<li>Call <a class="reference internal" href="#c.psa_get_key_attributes" title="psa_get_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_get_key_attributes()</span></code></a>.</li>
<li>Call <code class="docutils literal notranslate"><span class="pre">psa_get_key_xxx</span></code> functions to retrieve the attribute(s) that you are interested in.</li>
<li>Call <a class="reference internal" href="#c.psa_reset_key_attributes" title="psa_reset_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_reset_key_attributes()</span></code></a> to free any resources that may be used by the attribute structure.</li>
</ol>
<p>Once a key has been created, it is impossible to change its attributes.</p>
</div>
<div class="section" id="PSA_KEY_ATTRIBUTES_INIT">
<span id="c.PSA_KEY_ATTRIBUTES_INIT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ATTRIBUTES_INIT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_ATTRIBUTES_INIT  {0}</span>
</pre></div>
</div>
<p>This macro returns a suitable initializer for a key attribute structure of type <a class="reference internal" href="#c.psa_key_attributes_t" title="psa_key_attributes_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_attributes_t</span></code></a>.</p>
</div>
<div class="section" id="psa_key_attributes_init">
<span id="c.psa_key_attributes_init"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_attributes_init</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_attributes_t</span> <span class="nf">psa_key_attributes_init</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_key_attributes_t" title="psa_key_attributes_t"><code class="docutils literal notranslate"><span class="pre">psa_key_attributes_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Return an initial value for a key attributes structure.</p>
</div>
<div class="section" id="psa_set_key_id">
<span id="c.psa_set_key_id"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_set_key_id</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">psa_set_key_id</span><span class="p">(</span><span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span>
                    <span class="n">psa_key_id_t</span> <span class="n">id</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The attribute structure to write to.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">id</span></code></dt>
<dd>The persistent identifier for the key.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">void</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Declare a key as persistent and set its key identifier.</p>
<p>If the attribute structure currently declares the key as volatile (which is the default content of an attribute structure), this function sets the lifetime attribute to <a class="reference internal" href="#c.PSA_KEY_LIFETIME_PERSISTENT" title="PSA_KEY_LIFETIME_PERSISTENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_PERSISTENT</span></code></a>.</p>
<p>This function does not access storage, it merely stores the given value in the structure. The persistent key will be written to storage when the attribute structure is passed to a key creation function such as <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a>, <a class="reference internal" href="#c.psa_generate_key" title="psa_generate_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_generate_key()</span></code></a>, <a class="reference internal" href="#c.psa_key_derivation_output_key" title="psa_key_derivation_output_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_output_key()</span></code></a> or <a class="reference internal" href="#c.psa_copy_key" title="psa_copy_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_copy_key()</span></code></a>.</p>
<p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate each of its arguments exactly once.</p>
</div>
<div class="section" id="psa_set_key_lifetime">
<span id="c.psa_set_key_lifetime"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_set_key_lifetime</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">psa_set_key_lifetime</span><span class="p">(</span><span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span>
                          <span class="n">psa_key_lifetime_t</span> <span class="n">lifetime</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The attribute structure to write to.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">lifetime</span></code></dt>
<dd>The lifetime for the key. If this is <a class="reference internal" href="#c.PSA_KEY_LIFETIME_VOLATILE" title="PSA_KEY_LIFETIME_VOLATILE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code></a>, the key will be volatile, and the key identifier attribute is reset to 0.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">void</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Set the location of a persistent key.</p>
<p>To make a key persistent, you must give it a persistent key identifier with <a class="reference internal" href="#c.psa_set_key_id" title="psa_set_key_id"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_id()</span></code></a>. By default, a key that has a persistent identifier is stored in the default storage area identifier by <a class="reference internal" href="#c.PSA_KEY_LIFETIME_PERSISTENT" title="PSA_KEY_LIFETIME_PERSISTENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_PERSISTENT</span></code></a>. Call this function to choose a storage area, or to explicitly declare the key as volatile.</p>
<p>This function does not access storage, it merely stores the given value in the structure. The persistent key will be written to storage when the attribute structure is passed to a key creation function such as <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a>, <a class="reference internal" href="#c.psa_generate_key" title="psa_generate_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_generate_key()</span></code></a>, <a class="reference internal" href="#c.psa_key_derivation_output_key" title="psa_key_derivation_output_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_output_key()</span></code></a> or <a class="reference internal" href="#c.psa_copy_key" title="psa_copy_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_copy_key()</span></code></a>.</p>
<p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate each of its arguments exactly once.</p>
</div>
<div class="section" id="psa_get_key_id">
<span id="c.psa_get_key_id"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_get_key_id</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_id_t</span> <span class="nf">psa_get_key_id</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The key attribute structure to query.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_key_id_t" title="psa_key_id_t"><code class="docutils literal notranslate"><span class="pre">psa_key_id_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p>The persistent identifier stored in the attribute structure. This value is unspecified if the attribute structure declares the key as volatile.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Retrieve the key identifier from key attributes.</p>
<p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate its argument exactly once.</p>
</div>
<div class="section" id="psa_get_key_lifetime">
<span id="c.psa_get_key_lifetime"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_get_key_lifetime</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_lifetime_t</span> <span class="nf">psa_get_key_lifetime</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The key attribute structure to query.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_key_lifetime_t" title="psa_key_lifetime_t"><code class="docutils literal notranslate"><span class="pre">psa_key_lifetime_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p>The lifetime value stored in the attribute structure.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Retrieve the lifetime from key attributes.</p>
<p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate its argument exactly once.</p>
</div>
<div class="section" id="psa_set_key_usage_flags">
<span id="c.psa_set_key_usage_flags"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_set_key_usage_flags</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">psa_set_key_usage_flags</span><span class="p">(</span><span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span>
                             <span class="n">psa_key_usage_t</span> <span class="n">usage_flags</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The attribute structure to write to.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">usage_flags</span></code></dt>
<dd>The usage flags to write.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">void</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Declare usage flags for a key.</p>
<p>Usage flags are part of a key’s usage policy. They encode what kind of operations are permitted on the key. For more details, refer to the documentation of the type <a class="reference internal" href="#c.psa_key_usage_t" title="psa_key_usage_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_usage_t</span></code></a>.</p>
<p>This function overwrites any usage flags previously set in <code class="docutils literal notranslate"><span class="pre">attributes</span></code>.</p>
<p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate each of its arguments exactly once.</p>
</div>
<div class="section" id="psa_get_key_usage_flags">
<span id="c.psa_get_key_usage_flags"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_get_key_usage_flags</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_usage_t</span> <span class="nf">psa_get_key_usage_flags</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The key attribute structure to query.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_key_usage_t" title="psa_key_usage_t"><code class="docutils literal notranslate"><span class="pre">psa_key_usage_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p>The usage flags stored in the attribute structure.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Retrieve the usage flags from key attributes.</p>
<p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate its argument exactly once.</p>
</div>
<div class="section" id="psa_set_key_algorithm">
<span id="c.psa_set_key_algorithm"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_set_key_algorithm</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">psa_set_key_algorithm</span><span class="p">(</span><span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span>
                           <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The attribute structure to write to.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The permitted algorithm policy to write.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">void</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Declare the permitted algorithm policy for a key.</p>
<p>The permitted algorithm policy of a key encodes which algorithm or algorithms are permitted to be used with this key.</p>
<p>This function overwrites any algorithm policy previously set in <code class="docutils literal notranslate"><span class="pre">attributes</span></code>.</p>
<p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate each of its arguments exactly once.</p>
</div>
<div class="section" id="psa_get_key_algorithm">
<span id="c.psa_get_key_algorithm"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_get_key_algorithm</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_algorithm_t</span> <span class="nf">psa_get_key_algorithm</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The key attribute structure to query.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p>The algorithm stored in the attribute structure.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Retrieve the algorithm policy from key attributes.</p>
<p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate its argument exactly once.</p>
</div>
<div class="section" id="psa_set_key_type">
<span id="c.psa_set_key_type"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_set_key_type</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">psa_set_key_type</span><span class="p">(</span><span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span>
                      <span class="n">psa_key_type_t</span> <span class="n">type</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The attribute structure to write to.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd>The key type to write.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">void</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Declare the type of a key.</p>
<p>This function overwrites any key type previously set in <code class="docutils literal notranslate"><span class="pre">attributes</span></code>.</p>
<p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate each of its arguments exactly once.</p>
</div>
<div class="section" id="psa_set_key_bits">
<span id="c.psa_set_key_bits"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_set_key_bits</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">psa_set_key_bits</span><span class="p">(</span><span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span>
                      <span class="kt">size_t</span> <span class="n">bits</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The attribute structure to write to.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">bits</span></code></dt>
<dd>The key size in bits.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">void</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Declare the size of a key.</p>
<p>This function overwrites any key size previously set in <code class="docutils literal notranslate"><span class="pre">attributes</span></code>.</p>
<p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate each of its arguments exactly once.</p>
</div>
<div class="section" id="psa_get_key_type">
<span id="c.psa_get_key_type"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_get_key_type</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_type_t</span> <span class="nf">psa_get_key_type</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The key attribute structure to query.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p>The key type stored in the attribute structure.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Retrieve the key type from key attributes.</p>
<p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate its argument exactly once.</p>
</div>
<div class="section" id="psa_get_key_bits">
<span id="c.psa_get_key_bits"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_get_key_bits</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">size_t</span> <span class="nf">psa_get_key_bits</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The key attribute structure to query.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">size_t</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p>The key size stored in the attribute structure, in bits.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Retrieve the key size from key attributes.</p>
<p>This function may be declared as <code class="docutils literal notranslate"><span class="pre">static</span></code> (i.e. without external linkage). This function may be provided as a function-like macro, but in this case it must evaluate its argument exactly once.</p>
</div>
<div class="section" id="psa_get_key_attributes">
<span id="c.psa_get_key_attributes"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_get_key_attributes</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_get_key_attributes</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                                    <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to query.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>On success, the attributes of the key. On failure, equivalent to a freshly-initialized structure.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Retrieve the attributes of a key.</p>
<p>This function first resets the attribute structure as with <a class="reference internal" href="#c.psa_reset_key_attributes" title="psa_reset_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_reset_key_attributes()</span></code></a>. It then copies the attributes of the given key into the given attribute structure.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This function may allocate memory or other resources. Once you have called this function on an attribute structure, you must call <a class="reference internal" href="#c.psa_reset_key_attributes" title="psa_reset_key_attributes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_reset_key_attributes()</span></code></a> to free these resources.</p>
</div>
</div>
<div class="section" id="psa_reset_key_attributes">
<span id="c.psa_reset_key_attributes"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_reset_key_attributes</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">psa_reset_key_attributes</span><span class="p">(</span><span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The attribute structure to reset.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><code class="docutils literal notranslate"><span class="pre">void</span></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Reset a key attribute structure to a freshly initialized state.</p>
<p>You must initialize the attribute structure as described in the documentation of the type <a class="reference internal" href="#c.psa_key_attributes_t" title="psa_key_attributes_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_attributes_t</span></code></a> before calling this function. Once the structure has been initialized, you may call this function at any time.</p>
<p>This function frees any auxiliary resources that the structure may contain.</p>
</div>
</div>
<div class="section" id="key-management">
<h1>Key management</h1>
<div class="section" id="psa_open_key">
<span id="c.psa_open_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_open_key</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_open_key</span><span class="p">(</span><span class="n">psa_key_id_t</span> <span class="n">id</span><span class="p">,</span>
                          <span class="n">psa_key_handle_t</span> <span class="o">*</span> <span class="n">handle</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">id</span></code></dt>
<dd>The persistent identifier of the key.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>On success, a handle to the key.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success. The application can now use the value of <code class="docutils literal notranslate"><span class="pre">*handle</span></code> to access the key.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">id</span></code> is invalid.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The specified key exists, but the application does not have the permission to access it. Note that this specification does not define any way to create such a key, but it may be possible through implementation-specific means.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_STORAGE_FAILURE" title="PSA_ERROR_STORAGE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_STORAGE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Open a handle to an existing persistent key.</p>
<p>Open a handle to a persistent key. A key is persistent if it was created with a lifetime other than <a class="reference internal" href="#c.PSA_KEY_LIFETIME_VOLATILE" title="PSA_KEY_LIFETIME_VOLATILE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code></a>. A persistent key always has a nonzero key identifier, set with <a class="reference internal" href="#c.psa_set_key_id" title="psa_set_key_id"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_set_key_id()</span></code></a> when creating the key. Implementations may provide additional pre-provisioned keys with identifiers in the range <a class="reference internal" href="#c.PSA_KEY_ID_VENDOR_MIN" title="PSA_KEY_ID_VENDOR_MIN"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MIN</span></code></a>–<a class="reference internal" href="#c.PSA_KEY_ID_VENDOR_MAX" title="PSA_KEY_ID_VENDOR_MAX"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MAX</span></code></a>.</p>
<p>The application must eventually close the handle with <a class="reference internal" href="#c.psa_close_key" title="psa_close_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_close_key()</span></code></a> to release associated resources. If the application dies without calling <a class="reference internal" href="#c.psa_close_key" title="psa_close_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_close_key()</span></code></a>, the implementation should perform the equivalent of a call to <a class="reference internal" href="#c.psa_close_key" title="psa_close_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_close_key()</span></code></a>.</p>
<p>Implementations may provide additional keys that can be opened with <a class="reference internal" href="#c.psa_open_key" title="psa_open_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_open_key()</span></code></a>. Such keys have a key identifier in the vendor range, as documented in the description of <a class="reference internal" href="#c.psa_key_id_t" title="psa_key_id_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_id_t</span></code></a>.</p>
</div>
<div class="section" id="psa_close_key">
<span id="c.psa_close_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_close_key</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_close_key</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>The key handle to close.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Close a key handle.</p>
<p>If the handle designates a volatile key, destroy the key material and free all associated resources, just like <a class="reference internal" href="#c.psa_destroy_key" title="psa_destroy_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_destroy_key()</span></code></a>.</p>
<p>If the handle designates a persistent key, free all resources associated with the key in volatile memory. The key in persistent storage is not affected and can be opened again later with <a class="reference internal" href="#c.psa_open_key" title="psa_open_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_open_key()</span></code></a>.</p>
<p>If the key is currently in use in a multipart operation, the multipart operation is aborted.</p>
</div>
</div>
<div class="section" id="key-import-and-export">
<h1>Key import and export</h1>
<div class="section" id="psa_import_key">
<span id="c.psa_import_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_import_key</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_import_key</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span>
                            <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">data</span><span class="p">,</span>
                            <span class="kt">size_t</span> <span class="n">data_length</span><span class="p">,</span>
                            <span class="n">psa_key_handle_t</span> <span class="o">*</span> <span class="n">handle</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The attributes for the new key. The key size is always determined from the <code class="docutils literal notranslate"><span class="pre">data</span></code> buffer. If the key size in <code class="docutils literal notranslate"><span class="pre">attributes</span></code> is nonzero, it must be equal to the size from <code class="docutils literal notranslate"><span class="pre">data</span></code>.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">data</span></code></dt>
<dd>Buffer containing the key data. The content of this buffer is interpreted according to the type declared in <code class="docutils literal notranslate"><span class="pre">attributes</span></code>. All implementations must support at least the format described in the documentation of <a class="reference internal" href="#c.psa_export_key" title="psa_export_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_key()</span></code></a> or <a class="reference internal" href="#c.psa_export_public_key" title="psa_export_public_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_public_key()</span></code></a> for the chosen type. Implementations may allow other formats, but should be conservative: implementations should err on the side of rejecting content if it may be erroneous (e.g. wrong type or truncated data).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">data_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">data</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>On success, a handle to the newly created key. <code class="docutils literal notranslate"><span class="pre">0</span></code> on failure.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success. If the key is persistent, the key material and the key’s metadata have been saved to persistent storage.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_ALREADY_EXISTS" title="PSA_ERROR_ALREADY_EXISTS"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_ALREADY_EXISTS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>This is an attempt to create a persistent key, and there is already a persistent key with the given identifier.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The key type or key size is not supported, either by the implementation in general or in this particular persistent location.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The key attributes, as a whole, are invalid.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The key data is not correctly formatted.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size in <code class="docutils literal notranslate"><span class="pre">attributes</span></code> is nonzero and does not match the size of the key data.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_STORAGE" title="PSA_ERROR_INSUFFICIENT_STORAGE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_STORAGE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_STORAGE_FAILURE" title="PSA_ERROR_STORAGE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_STORAGE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Import a key in binary format.</p>
<p>This function supports any output from <a class="reference internal" href="#c.psa_export_key" title="psa_export_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_key()</span></code></a>. Refer to the documentation of <a class="reference internal" href="#c.psa_export_public_key" title="psa_export_public_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_public_key()</span></code></a> for the format of public keys and to the documentation of <a class="reference internal" href="#c.psa_export_key" title="psa_export_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_key()</span></code></a> for the format for other key types.</p>
<p>This specification supports a single format for each key type. Implementations may support other formats as long as the standard format is supported. Implementations that support other formats should ensure that the formats are clearly unambiguous so as to minimize the risk that an invalid input is accidentally interpreted according to a different format.</p>
</div>
<div class="section" id="psa_destroy_key">
<span id="c.psa_destroy_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_destroy_key</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_destroy_key</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to erase.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The key material has been erased.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The key cannot be erased because it is read-only, either due to a policy or due to physical restrictions.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>There was an failure in communication with the cryptoprocessor. The key material may still be present in the cryptoprocessor.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_STORAGE_FAILURE" title="PSA_ERROR_STORAGE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_STORAGE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The storage is corrupted. Implementations shall make a best effort to erase key material even in this stage, however applications should be aware that it may be impossible to guarantee that the key material is not recoverable in such cases.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>An unexpected condition which is not a storage corruption or a communication failure occurred. The cryptoprocessor may have been compromised.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Destroy a key.</p>
<p>This function destroys a key from both volatile memory and, if applicable, non-volatile storage. Implementations shall make a best effort to ensure that that the key material cannot be recovered.</p>
<p>This function also erases any metadata such as policies and frees all resources associated with the key.</p>
</div>
<div class="section" id="psa_export_key">
<span id="c.psa_export_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_export_key</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_export_key</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                            <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">data</span><span class="p">,</span>
                            <span class="kt">size_t</span> <span class="n">data_size</span><span class="p">,</span>
                            <span class="kt">size_t</span> <span class="o">*</span> <span class="n">data_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to export.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">data</span></code></dt>
<dd>Buffer where the key data is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">data_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">data</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">data_length</span></code></dt>
<dd>On success, the number of bytes that make up the key data.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The key does not have the <a class="reference internal" href="#c.PSA_KEY_USAGE_EXPORT" title="PSA_KEY_USAGE_EXPORT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_EXPORT</span></code></a> flag.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of the <code class="docutils literal notranslate"><span class="pre">data</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_KEY_EXPORT_MAX_SIZE" title="PSA_KEY_EXPORT_MAX_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_MAX_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">type</span></code>, <code class="docutils literal notranslate"><span class="pre">bits</span></code>) where <code class="docutils literal notranslate"><span class="pre">type</span></code> is the key type and <code class="docutils literal notranslate"><span class="pre">bits</span></code> is the key size in bits.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Export a key in binary format.</p>
<p>The output of this function can be passed to <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a> to create an equivalent object.</p>
<p>If the implementation of <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a> supports other formats beyond the format specified here, the output from <a class="reference internal" href="#c.psa_export_key" title="psa_export_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_key()</span></code></a> must use the representation specified here, not the original representation.</p>
<p>For standard key types, the output format is as follows:</p>
<ul>
<li><p class="first">For symmetric keys (including MAC keys), the format is the raw bytes of the key.</p>
</li>
<li><p class="first">For DES, the key data consists of 8 bytes. The parity bits must be correct.</p>
</li>
<li><p class="first">For Triple-DES, the format is the concatenation of the two or three DES keys.</p>
</li>
<li><p class="first">For RSA key pairs (<a class="reference internal" href="#c.PSA_KEY_TYPE_RSA_KEY_PAIR" title="PSA_KEY_TYPE_RSA_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_KEY_PAIR</span></code></a>), the format is the non-encrypted DER encoding of the representation defined by PKCS#1 (RFC 8017) as <code class="docutils literal notranslate"><span class="pre">RSAPrivateKey</span></code>, version 0.</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">RSAPrivateKey</span> <span class="o">::=</span> <span class="n">SEQUENCE</span> <span class="p">{</span>
    <span class="n">version</span>             <span class="n">INTEGER</span><span class="p">,</span>  <span class="o">--</span> <span class="n">must</span> <span class="n">be</span> <span class="mi">0</span>
    <span class="n">modulus</span>             <span class="n">INTEGER</span><span class="p">,</span>  <span class="o">--</span> <span class="n">n</span>
    <span class="n">publicExponent</span>      <span class="n">INTEGER</span><span class="p">,</span>  <span class="o">--</span> <span class="n">e</span>
    <span class="n">privateExponent</span>     <span class="n">INTEGER</span><span class="p">,</span>  <span class="o">--</span> <span class="n">d</span>
    <span class="n">prime1</span>              <span class="n">INTEGER</span><span class="p">,</span>  <span class="o">--</span> <span class="n">p</span>
    <span class="n">prime2</span>              <span class="n">INTEGER</span><span class="p">,</span>  <span class="o">--</span> <span class="n">q</span>
    <span class="n">exponent1</span>           <span class="n">INTEGER</span><span class="p">,</span>  <span class="o">--</span> <span class="n">d</span> <span class="n">mod</span> <span class="p">(</span><span class="n">p</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="n">exponent2</span>           <span class="n">INTEGER</span><span class="p">,</span>  <span class="o">--</span> <span class="n">d</span> <span class="n">mod</span> <span class="p">(</span><span class="n">q</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
    <span class="n">coefficient</span>         <span class="n">INTEGER</span><span class="p">,</span>  <span class="o">--</span> <span class="p">(</span><span class="n">inverse</span> <span class="n">of</span> <span class="n">q</span><span class="p">)</span> <span class="n">mod</span> <span class="n">p</span>
<span class="p">}</span>
</pre></div>
</div>
</li>
<li><p class="first">For elliptic curve key pairs (key types for which <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_ECC_KEY_PAIR" title="PSA_KEY_TYPE_IS_ECC_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC_KEY_PAIR</span></code></a> is true), the format is a representation of the private value as a <code class="docutils literal notranslate"><span class="pre">ceiling(m/8)</span></code>-byte string where <code class="docutils literal notranslate"><span class="pre">m</span></code> is the bit size associated with the curve, i.e. the bit size of the order of the curve’s coordinate field. This byte string is in little-endian order for Montgomery curves (curve types <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVEXXX</span></code>), and in big-endian order for Weierstrass curves (curve types <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECTXXX</span></code>, <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECPXXX</span></code> and <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_PXXX</span></code>). This is the content of the <code class="docutils literal notranslate"><span class="pre">privateKey</span></code> field of the <code class="docutils literal notranslate"><span class="pre">ECPrivateKey</span></code> format defined by RFC 5915.</p>
</li>
<li><p class="first">For Diffie-Hellman key exchange key pairs (key types for which <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_DH_KEY_PAIR" title="PSA_KEY_TYPE_IS_DH_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH_KEY_PAIR</span></code></a> is true), the format is the representation of the private key <code class="docutils literal notranslate"><span class="pre">x</span></code> as a big-endian byte string. The length of the byte string is the private key size in bytes (leading zeroes are not stripped).</p>
</li>
<li><p class="first">For public keys (key types for which <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_PUBLIC_KEY" title="PSA_KEY_TYPE_IS_PUBLIC_KEY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_PUBLIC_KEY</span></code></a> is true), the format is the same as for <a class="reference internal" href="#c.psa_export_public_key" title="psa_export_public_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_public_key()</span></code></a>.</p>
</li>
</ul>
<p>The policy on the key must have the usage flag <a class="reference internal" href="#c.PSA_KEY_USAGE_EXPORT" title="PSA_KEY_USAGE_EXPORT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_EXPORT</span></code></a> set.</p>
</div>
<div class="section" id="psa_export_public_key">
<span id="c.psa_export_public_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_export_public_key</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_export_public_key</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                                   <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">data</span><span class="p">,</span>
                                   <span class="kt">size_t</span> <span class="n">data_size</span><span class="p">,</span>
                                   <span class="kt">size_t</span> <span class="o">*</span> <span class="n">data_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to export.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">data</span></code></dt>
<dd>Buffer where the key data is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">data_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">data</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">data_length</span></code></dt>
<dd>On success, the number of bytes that make up the key data.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The key is neither a public key nor a key pair.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of the <code class="docutils literal notranslate"><span class="pre">data</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_KEY_EXPORT_MAX_SIZE" title="PSA_KEY_EXPORT_MAX_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_MAX_SIZE</span></code></a>(<a class="reference internal" href="#c.PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR" title="PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR</span></code></a>(<code class="docutils literal notranslate"><span class="pre">type</span></code>), <code class="docutils literal notranslate"><span class="pre">bits</span></code>) where <code class="docutils literal notranslate"><span class="pre">type</span></code> is the key type and <code class="docutils literal notranslate"><span class="pre">bits</span></code> is the key size in bits.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Export a public key or the public part of a key pair in binary format.</p>
<p>The output of this function can be passed to <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a> to create an object that is equivalent to the public key.</p>
<p>This specification supports a single format for each key type. Implementations may support other formats as long as the standard format is supported. Implementations that support other formats should ensure that the formats are clearly unambiguous so as to minimize the risk that an invalid input is accidentally interpreted according to a different format.</p>
<p>For standard key types, the output format is as follows:</p>
<ul>
<li><p class="first">For RSA public keys (<a class="reference internal" href="#c.PSA_KEY_TYPE_RSA_PUBLIC_KEY" title="PSA_KEY_TYPE_RSA_PUBLIC_KEY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_PUBLIC_KEY</span></code></a>), the DER encoding of the representation defined by RFC 3279 §2.3.1 as <code class="docutils literal notranslate"><span class="pre">RSAPublicKey</span></code>.</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">RSAPublicKey</span> <span class="o">::=</span> <span class="n">SEQUENCE</span> <span class="p">{</span>
   <span class="n">modulus</span>            <span class="n">INTEGER</span><span class="p">,</span>    <span class="o">--</span> <span class="n">n</span>
   <span class="n">publicExponent</span>     <span class="n">INTEGER</span>  <span class="p">}</span>  <span class="o">--</span> <span class="n">e</span>
</pre></div>
</div>
</li>
<li><p class="first">For elliptic curve public keys (key types for which <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY" title="PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY</span></code></a> is true), the format is the uncompressed representation defined by SEC1 §2.3.3 as the content of an ECPoint. Let <code class="docutils literal notranslate"><span class="pre">m</span></code> be the bit size associated with the curve, i.e. the bit size of <code class="docutils literal notranslate"><span class="pre">q</span></code> for a curve over <code class="docutils literal notranslate"><span class="pre">F_q</span></code>. The representation consists of:</p>
<ul class="simple">
<li>The byte 0x04;</li>
<li><code class="docutils literal notranslate"><span class="pre">x_P</span></code> as a <code class="docutils literal notranslate"><span class="pre">ceiling(m/8)</span></code>-byte string, big-endian;</li>
<li><code class="docutils literal notranslate"><span class="pre">y_P</span></code> as a <code class="docutils literal notranslate"><span class="pre">ceiling(m/8)</span></code>-byte string, big-endian.</li>
</ul>
</li>
<li><p class="first">For Diffie-Hellman key exchange public keys (key types for which <a class="reference internal" href="#c.PSA_KEY_TYPE_IS_DH_PUBLIC_KEY" title="PSA_KEY_TYPE_IS_DH_PUBLIC_KEY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH_PUBLIC_KEY</span></code></a> is true), the format is the representation of the public key <code class="docutils literal notranslate"><span class="pre">y</span> <span class="pre">=</span> <span class="pre">g^x</span> <span class="pre">mod</span> <span class="pre">p</span></code> as a big-endian byte string. The length of the byte string is the length of the base prime <code class="docutils literal notranslate"><span class="pre">p</span></code> in bytes.</p>
</li>
</ul>
<p>Exporting a public key object or the public part of a key pair is always permitted, regardless of the key’s usage flags.</p>
</div>
<div class="section" id="psa_copy_key">
<span id="c.psa_copy_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_copy_key</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_copy_key</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">source_handle</span><span class="p">,</span>
                          <span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span>
                          <span class="n">psa_key_handle_t</span> <span class="o">*</span> <span class="n">target_handle</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">source_handle</span></code></dt>
<dd>The key to copy. It must be a valid key handle.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd><p class="first">The attributes for the new key. They are used as follows:</p>
<ul class="last simple">
<li>The key type and size may be 0. If either is nonzero, it must match the corresponding attribute of the source key.</li>
<li>The key location (the lifetime and, for persistent keys, the key identifier) is used directly.</li>
<li>The policy constraints (usage flags and algorithm policy) are combined from the source key and <code class="docutils literal notranslate"><span class="pre">attributes</span></code> so that both sets of restrictions apply, as described in the documentation of this function.</li>
</ul>
</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">target_handle</span></code></dt>
<dd>On success, a handle to the newly created key. <code class="docutils literal notranslate"><span class="pre">0</span></code> on failure.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">source_handle</span></code> is invalid.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_ALREADY_EXISTS" title="PSA_ERROR_ALREADY_EXISTS"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_ALREADY_EXISTS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>This is an attempt to create a persistent key, and there is already a persistent key with the given identifier.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The lifetime or identifier in <code class="docutils literal notranslate"><span class="pre">attributes</span></code> are invalid.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The policy constraints on the source and specified in <code class="docutils literal notranslate"><span class="pre">attributes</span></code> are incompatible.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">attributes</span></code> specifies a key type or key size which does not match the attributes of the source key.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The source key does not have the <a class="reference internal" href="#c.PSA_KEY_USAGE_COPY" title="PSA_KEY_USAGE_COPY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_COPY</span></code></a> usage flag.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The source key is not exportable and its lifetime does not allow copying it to the target’s lifetime.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_STORAGE" title="PSA_ERROR_INSUFFICIENT_STORAGE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_STORAGE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Make a copy of a key.</p>
<p>Copy key material from one location to another.</p>
<p>This function is primarily useful to copy a key from one location to another, since it populates a key using the material from another key which may have a different lifetime.</p>
<p>This function may be used to share a key with a different party, subject to implementation-defined restrictions on key sharing.</p>
<p>The policy on the source key must have the usage flag <a class="reference internal" href="#c.PSA_KEY_USAGE_COPY" title="PSA_KEY_USAGE_COPY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_COPY</span></code></a> set. This flag is sufficient to permit the copy if the key has the lifetime <a class="reference internal" href="#c.PSA_KEY_LIFETIME_VOLATILE" title="PSA_KEY_LIFETIME_VOLATILE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code></a> or <a class="reference internal" href="#c.PSA_KEY_LIFETIME_PERSISTENT" title="PSA_KEY_LIFETIME_PERSISTENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_PERSISTENT</span></code></a>. Some secure elements do not provide a way to copy a key without making it extractable from the secure element. If a key is located in such a secure element, then the key must have both usage flags <a class="reference internal" href="#c.PSA_KEY_USAGE_COPY" title="PSA_KEY_USAGE_COPY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_COPY</span></code></a> and <a class="reference internal" href="#c.PSA_KEY_USAGE_EXPORT" title="PSA_KEY_USAGE_EXPORT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_EXPORT</span></code></a> in order to make a copy of the key outside the secure element.</p>
<p>The resulting key may only be used in a way that conforms to both the policy of the original key and the policy specified in the <code class="docutils literal notranslate"><span class="pre">attributes</span></code> parameter:</p>
<ul class="simple">
<li>The usage flags on the resulting key are the bitwise-and of the usage flags on the source policy and the usage flags in <code class="docutils literal notranslate"><span class="pre">attributes</span></code>.</li>
<li>If both allow the same algorithm or wildcard-based algorithm policy, the resulting key has the same algorithm policy.</li>
<li>If either of the policies allows an algorithm and the other policy allows a wildcard-based algorithm policy that includes this algorithm, the resulting key allows the same algorithm.</li>
<li>If the policies do not allow any algorithm in common, this function fails with the status <a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a>.</li>
</ul>
<p>The effect of this function on implementation-defined attributes is implementation-defined.</p>
</div>
</div>
<div class="section" id="message-digests">
<h1>Message digests</h1>
<div class="section" id="psa_hash_operation_t">
<span id="c.psa_hash_operation_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_operation_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">psa_hash_operation_s</span> <span class="n">psa_hash_operation_t</span><span class="p">;</span>
</pre></div>
</div>
<p>The type of the state data structure for multipart hash operations.</p>
<p>Before calling any function on a hash operation object, the application must initialize it by any of the following means:</p>
<ul>
<li><p class="first">Set the structure to all-bits-zero, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_hash_operation_t</span> <span class="n">operation</span><span class="p">;</span>
<span class="n">memset</span><span class="p">(</span><span class="o">&amp;</span><span class="n">operation</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">operation</span><span class="p">));</span>
</pre></div>
</div>
</li>
<li><p class="first">Initialize the structure to logical zero values, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_hash_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">};</span>
</pre></div>
</div>
</li>
<li><p class="first">Initialize the structure to the initializer <a class="reference internal" href="#c.PSA_HASH_OPERATION_INIT" title="PSA_HASH_OPERATION_INIT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_HASH_OPERATION_INIT</span></code></a>, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_hash_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="n">PSA_HASH_OPERATION_INIT</span><span class="p">;</span>
</pre></div>
</div>
</li>
<li><p class="first">Assign the result of the function <a class="reference internal" href="#c.psa_hash_operation_init" title="psa_hash_operation_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_operation_init()</span></code></a> to the structure, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_hash_operation_t</span> <span class="n">operation</span><span class="p">;</span>
<span class="n">operation</span> <span class="o">=</span> <span class="n">psa_hash_operation_init</span><span class="p">();</span>
</pre></div>
</div>
</li>
</ul>
<p>This is an implementation-defined <code class="docutils literal notranslate"><span class="pre">struct</span></code>. Applications should not make any assumptions about the content of this structure except as directed by the documentation of a specific implementation.</p>
</div>
<div class="section" id="PSA_HASH_OPERATION_INIT">
<span id="c.PSA_HASH_OPERATION_INIT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_HASH_OPERATION_INIT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_HASH_OPERATION_INIT  {0}</span>
</pre></div>
</div>
<p>This macro returns a suitable initializer for a hash operation object of type <a class="reference internal" href="#c.psa_hash_operation_t" title="psa_hash_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_hash_operation_t</span></code></a>.</p>
</div>
<div class="section" id="psa_hash_compute">
<span id="c.psa_hash_compute"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_compute</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_compute</span><span class="p">(</span><span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span>
                              <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span>
                              <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span>
                              <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">hash</span><span class="p">,</span>
                              <span class="kt">size_t</span> <span class="n">hash_size</span><span class="p">,</span>
                              <span class="kt">size_t</span> <span class="o">*</span> <span class="n">hash_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The hash algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt>
<dd>Buffer containing the message to hash.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">hash</span></code></dt>
<dd>Buffer where the hash is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">hash_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">hash</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">hash_length</span></code></dt>
<dd>On success, the number of bytes that make up the hash value. This is always <a class="reference internal" href="#c.PSA_HASH_SIZE" title="PSA_HASH_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_HASH_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a hash algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Calculate the hash (digest) of a message.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">To verify the hash of a message against an expected value, use <a class="reference internal" href="#c.psa_hash_compare" title="psa_hash_compare"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_compare()</span></code></a> instead.</p>
</div>
</div>
<div class="section" id="psa_hash_compare">
<span id="c.psa_hash_compare"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_compare</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_compare</span><span class="p">(</span><span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span>
                              <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span>
                              <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span>
                              <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">hash</span><span class="p">,</span>
                              <span class="k">const</span> <span class="kt">size_t</span> <span class="n">hash_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The hash algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt>
<dd>Buffer containing the message to hash.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">hash</span></code></dt>
<dd>Buffer containing the expected hash value.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">hash_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">hash</span></code> buffer in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The expected hash is identical to the actual hash of the input.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_SIGNATURE" title="PSA_ERROR_INVALID_SIGNATURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The hash of the message was calculated successfully, but it differs from the expected hash.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a hash algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Calculate the hash (digest) of a message and compare it with a reference value.</p>
</div>
<div class="section" id="psa_hash_operation_init">
<span id="c.psa_hash_operation_init"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_operation_init</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_hash_operation_t</span> <span class="nf">psa_hash_operation_init</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_hash_operation_t" title="psa_hash_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_hash_operation_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Return an initial value for a hash operation object.</p>
</div>
<div class="section" id="psa_hash_setup">
<span id="c.psa_hash_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_setup</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_setup</span><span class="p">(</span><span class="n">psa_hash_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                            <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The operation object to set up. It must have been initialized as per the documentation for <a class="reference internal" href="#c.psa_hash_operation_t" title="psa_hash_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_hash_operation_t</span></code></a> and not yet in use.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The hash algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a hash algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (already set up and not subsequently completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Set up a multipart hash operation.</p>
<p>The sequence of operations to calculate a hash (message digest) is as follows:</p>
<ol class="arabic simple">
<li>Allocate an operation object which will be passed to all the functions listed here.</li>
<li>Initialize the operation object with one of the methods described in the documentation for <a class="reference internal" href="#c.psa_hash_operation_t" title="psa_hash_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_hash_operation_t</span></code></a>, e.g. PSA_HASH_OPERATION_INIT.</li>
<li>Call <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a> to specify the algorithm.</li>
<li>Call <a class="reference internal" href="#c.psa_hash_update" title="psa_hash_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_update()</span></code></a> zero, one or more times, passing a fragment of the message each time. The hash that is calculated is the hash of the concatenation of these messages in order.</li>
<li>To calculate the hash, call <a class="reference internal" href="#c.psa_hash_finish" title="psa_hash_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_finish()</span></code></a>. To compare the hash with an expected value, call <a class="reference internal" href="#c.psa_hash_verify" title="psa_hash_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_verify()</span></code></a>.</li>
</ol>
<p>The application may call <a class="reference internal" href="#c.psa_hash_abort" title="psa_hash_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_abort()</span></code></a> at any time after the operation has been initialized.</p>
<p>After a successful call to <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a>, the application must eventually terminate the operation. The following events terminate an operation:</p>
<ul class="simple">
<li>A failed call to <a class="reference internal" href="#c.psa_hash_update" title="psa_hash_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_update()</span></code></a>.</li>
<li>A call to <a class="reference internal" href="#c.psa_hash_finish" title="psa_hash_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_finish()</span></code></a>, <a class="reference internal" href="#c.psa_hash_verify" title="psa_hash_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_verify()</span></code></a> or <a class="reference internal" href="#c.psa_hash_abort" title="psa_hash_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_abort()</span></code></a>.</li>
</ul>
</div>
<div class="section" id="psa_hash_update">
<span id="c.psa_hash_update"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_update</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_update</span><span class="p">(</span><span class="n">psa_hash_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                             <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active hash operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt>
<dd>Buffer containing the message fragment to hash.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, or already completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Add a message fragment to a multipart hash operation.</p>
<p>The application must call <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a> before calling this function.</p>
<p>If this function returns an error status, the operation becomes inactive.</p>
</div>
<div class="section" id="psa_hash_finish">
<span id="c.psa_hash_finish"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_finish</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_finish</span><span class="p">(</span><span class="n">psa_hash_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                             <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">hash</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="n">hash_size</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="o">*</span> <span class="n">hash_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active hash operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">hash</span></code></dt>
<dd>Buffer where the hash is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">hash_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">hash</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">hash_length</span></code></dt>
<dd>On success, the number of bytes that make up the hash value. This is always <a class="reference internal" href="#c.PSA_HASH_SIZE" title="PSA_HASH_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_HASH_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the hash algorithm that is calculated.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, or already completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of the <code class="docutils literal notranslate"><span class="pre">hash</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_HASH_SIZE" title="PSA_HASH_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_HASH_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the hash algorithm that is calculated.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Finish the calculation of the hash of a message.</p>
<p>The application must call <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a> before calling this function. This function calculates the hash of the message formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_hash_update" title="psa_hash_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_update()</span></code></a>.</p>
<p>When this function returns, the operation becomes inactive.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">Applications should not call this function if they expect a specific value for the hash. Call <a class="reference internal" href="#c.psa_hash_verify" title="psa_hash_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_verify()</span></code></a> instead. Beware that comparing integrity or authenticity data such as hash values with a function such as <code class="docutils literal notranslate"><span class="pre">memcmp</span></code> is risky because the time taken by the comparison may leak information about the hashed data which could allow an attacker to guess a valid hash and thereby bypass security controls.</p>
</div>
</div>
<div class="section" id="psa_hash_verify">
<span id="c.psa_hash_verify"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_verify</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_verify</span><span class="p">(</span><span class="n">psa_hash_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                             <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">hash</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="n">hash_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active hash operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">hash</span></code></dt>
<dd>Buffer containing the expected hash value.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">hash_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">hash</span></code> buffer in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The expected hash is identical to the actual hash of the message.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_SIGNATURE" title="PSA_ERROR_INVALID_SIGNATURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The hash of the message was calculated successfully, but it differs from the expected hash.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, or already completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Finish the calculation of the hash of a message and compare it with an expected value.</p>
<p>The application must call <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a> before calling this function. This function calculates the hash of the message formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_hash_update" title="psa_hash_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_update()</span></code></a>. It then compares the calculated hash with the expected hash passed as a parameter to this function.</p>
<p>When this function returns, the operation becomes inactive.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Implementations shall make the best effort to ensure that the comparison between the actual hash and the expected hash is performed in constant time.</p>
</div>
</div>
<div class="section" id="psa_hash_abort">
<span id="c.psa_hash_abort"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_abort</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_abort</span><span class="p">(</span><span class="n">psa_hash_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Initialized hash operation.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">operation</span></code> is not an active hash operation.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Abort a hash operation.</p>
<p>Aborting an operation frees all associated resources except for the <code class="docutils literal notranslate"><span class="pre">operation</span></code> structure itself. Once aborted, the operation object can be reused for another operation by calling <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a> again.</p>
<p>You may call this function any time after the operation object has been initialized by any of the following methods:</p>
<ul class="simple">
<li>A call to <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a>, whether it succeeds or not.</li>
<li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to all-bits-zero.</li>
<li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to logical zeros, e.g. <code class="docutils literal notranslate"><span class="pre">psa_hash_operation_t</span> <span class="pre">operation</span> <span class="pre">=</span> <span class="pre">{0}</span></code>.</li>
</ul>
<p>In particular, calling <a class="reference internal" href="#c.psa_hash_abort" title="psa_hash_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_abort()</span></code></a> after the operation has been terminated by a call to <a class="reference internal" href="#c.psa_hash_abort" title="psa_hash_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_abort()</span></code></a>, <a class="reference internal" href="#c.psa_hash_finish" title="psa_hash_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_finish()</span></code></a> or <a class="reference internal" href="#c.psa_hash_verify" title="psa_hash_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_verify()</span></code></a> is safe and has no effect.</p>
</div>
<div class="section" id="psa_hash_clone">
<span id="c.psa_hash_clone"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_hash_clone</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_hash_clone</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_hash_operation_t</span> <span class="o">*</span> <span class="n">source_operation</span><span class="p">,</span>
                            <span class="n">psa_hash_operation_t</span> <span class="o">*</span> <span class="n">target_operation</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">source_operation</span></code></dt>
<dd>The active hash operation to clone.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">target_operation</span></code></dt>
<dd>The operation object to set up. It must be initialized but not active.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">source_operation</span></code> is not an active hash operation.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">target_operation</span></code> is active.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Clone a hash operation.</p>
<p>This function copies the state of an ongoing hash operation to a new operation object. In other words, this function is equivalent to calling <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a> on <code class="docutils literal notranslate"><span class="pre">target_operation</span></code> with the same algorithm that <code class="docutils literal notranslate"><span class="pre">source_operation</span></code> was set up for, then <a class="reference internal" href="#c.psa_hash_update" title="psa_hash_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_update()</span></code></a> on <code class="docutils literal notranslate"><span class="pre">target_operation</span></code> with the same input that that was passed to <code class="docutils literal notranslate"><span class="pre">source_operation</span></code>. After this function returns, the two objects are independent, i.e. subsequent calls involving one of the objects do not affect the other object.</p>
</div>
</div>
<div class="section" id="message-authentication-codes">
<h1>Message authentication codes</h1>
<div class="section" id="psa_mac_operation_t">
<span id="c.psa_mac_operation_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">psa_mac_operation_s</span> <span class="n">psa_mac_operation_t</span><span class="p">;</span>
</pre></div>
</div>
<p>The type of the state data structure for multipart MAC operations.</p>
<p>Before calling any function on a MAC operation object, the application must initialize it by any of the following means:</p>
<ul>
<li><p class="first">Set the structure to all-bits-zero, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_mac_operation_t</span> <span class="n">operation</span><span class="p">;</span>
<span class="n">memset</span><span class="p">(</span><span class="o">&amp;</span><span class="n">operation</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">operation</span><span class="p">));</span>
</pre></div>
</div>
</li>
<li><p class="first">Initialize the structure to logical zero values, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_mac_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">};</span>
</pre></div>
</div>
</li>
<li><p class="first">Initialize the structure to the initializer <a class="reference internal" href="#c.PSA_MAC_OPERATION_INIT" title="PSA_MAC_OPERATION_INIT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_MAC_OPERATION_INIT</span></code></a>, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_mac_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="n">PSA_MAC_OPERATION_INIT</span><span class="p">;</span>
</pre></div>
</div>
</li>
<li><p class="first">Assign the result of the function <a class="reference internal" href="#c.psa_mac_operation_init" title="psa_mac_operation_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_operation_init()</span></code></a> to the structure, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_mac_operation_t</span> <span class="n">operation</span><span class="p">;</span>
<span class="n">operation</span> <span class="o">=</span> <span class="n">psa_mac_operation_init</span><span class="p">();</span>
</pre></div>
</div>
</li>
</ul>
<p>This is an implementation-defined <code class="docutils literal notranslate"><span class="pre">struct</span></code>. Applications should not make any assumptions about the content of this structure except as directed by the documentation of a specific implementation.</p>
</div>
<div class="section" id="PSA_MAC_OPERATION_INIT">
<span id="c.PSA_MAC_OPERATION_INIT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_MAC_OPERATION_INIT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_MAC_OPERATION_INIT  {0}</span>
</pre></div>
</div>
<p>This macro returns a suitable initializer for a MAC operation object of type <a class="reference internal" href="#c.psa_mac_operation_t" title="psa_mac_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code></a>.</p>
</div>
<div class="section" id="psa_mac_compute">
<span id="c.psa_mac_compute"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_compute</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_compute</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                             <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span>
                             <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span>
                             <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">mac</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="n">mac_size</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="o">*</span> <span class="n">mac_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The MAC algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt>
<dd>Buffer containing the input message.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">mac</span></code></dt>
<dd>Buffer where the MAC value is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">mac_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">mac</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">mac_length</span></code></dt>
<dd>On success, the number of bytes that make up the MAC value.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a MAC algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Calculate the MAC (message authentication code) of a message.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">To verify the MAC of a message against an expected value, use <a class="reference internal" href="#c.psa_mac_verify" title="psa_mac_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify()</span></code></a> instead. Beware that comparing integrity or authenticity data such as MAC values with a function such as <code class="docutils literal notranslate"><span class="pre">memcmp</span></code> is risky because the time taken by the comparison may leak information about the MAC value which could allow an attacker to guess a valid MAC and thereby bypass security controls.</p>
</div>
</div>
<div class="section" id="psa_mac_verify">
<span id="c.psa_mac_verify"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_verify</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_verify</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                            <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span>
                            <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span>
                            <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span>
                            <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">mac</span><span class="p">,</span>
                            <span class="k">const</span> <span class="kt">size_t</span> <span class="n">mac_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The MAC algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt>
<dd>Buffer containing the input message.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">mac</span></code></dt>
<dd>Buffer containing the expected MAC value.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">mac_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">mac</span></code> buffer in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The expected MAC is identical to the actual MAC of the input.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_SIGNATURE" title="PSA_ERROR_INVALID_SIGNATURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The MAC of the message was calculated successfully, but it differs from the expected value.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a MAC algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Calculate the MAC of a message and compare it with a reference value.</p>
</div>
<div class="section" id="psa_mac_operation_init">
<span id="c.psa_mac_operation_init"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_operation_init</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_mac_operation_t</span> <span class="nf">psa_mac_operation_init</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_mac_operation_t" title="psa_mac_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Return an initial value for a MAC operation object.</p>
</div>
<div class="section" id="psa_mac_sign_setup">
<span id="c.psa_mac_sign_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_sign_setup</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_sign_setup</span><span class="p">(</span><span class="n">psa_mac_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                <span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                                <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The operation object to set up. It must have been initialized as per the documentation for <a class="reference internal" href="#c.psa_mac_operation_t" title="psa_mac_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code></a> and not yet in use.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The MAC algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a MAC algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (already set up and not subsequently completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Set up a multipart MAC calculation operation.</p>
<p>This function sets up the calculation of the MAC (message authentication code) of a byte string. To verify the MAC of a message against an expected value, use <a class="reference internal" href="#c.psa_mac_verify_setup" title="psa_mac_verify_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_setup()</span></code></a> instead.</p>
<p>The sequence of operations to calculate a MAC is as follows:</p>
<ol class="arabic simple">
<li>Allocate an operation object which will be passed to all the functions listed here.</li>
<li>Initialize the operation object with one of the methods described in the documentation for <a class="reference internal" href="#c.psa_mac_operation_t" title="psa_mac_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code></a>, e.g. PSA_MAC_OPERATION_INIT.</li>
<li>Call <a class="reference internal" href="#c.psa_mac_sign_setup" title="psa_mac_sign_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_setup()</span></code></a> to specify the algorithm and key.</li>
<li>Call <a class="reference internal" href="#c.psa_mac_update" title="psa_mac_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_update()</span></code></a> zero, one or more times, passing a fragment of the message each time. The MAC that is calculated is the MAC of the concatenation of these messages in order.</li>
<li>At the end of the message, call <a class="reference internal" href="#c.psa_mac_sign_finish" title="psa_mac_sign_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_finish()</span></code></a> to finish calculating the MAC value and retrieve it.</li>
</ol>
<p>The application may call <a class="reference internal" href="#c.psa_mac_abort" title="psa_mac_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_abort()</span></code></a> at any time after the operation has been initialized.</p>
<p>After a successful call to <a class="reference internal" href="#c.psa_mac_sign_setup" title="psa_mac_sign_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_setup()</span></code></a>, the application must eventually terminate the operation through one of the following methods:</p>
<ul class="simple">
<li>A failed call to <a class="reference internal" href="#c.psa_mac_update" title="psa_mac_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_update()</span></code></a>.</li>
<li>A call to <a class="reference internal" href="#c.psa_mac_sign_finish" title="psa_mac_sign_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_finish()</span></code></a> or <a class="reference internal" href="#c.psa_mac_abort" title="psa_mac_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_abort()</span></code></a>.</li>
</ul>
</div>
<div class="section" id="psa_mac_verify_setup">
<span id="c.psa_mac_verify_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_verify_setup</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_verify_setup</span><span class="p">(</span><span class="n">psa_mac_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                  <span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                                  <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The operation object to set up. It must have been initialized as per the documentation for <a class="reference internal" href="#c.psa_mac_operation_t" title="psa_mac_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code></a> and not yet in use.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The MAC algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">key</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a MAC algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (already set up and not subsequently completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Set up a multipart MAC verification operation.</p>
<p>This function sets up the verification of the MAC (message authentication code) of a byte string against an expected value.</p>
<p>The sequence of operations to verify a MAC is as follows:</p>
<ol class="arabic simple">
<li>Allocate an operation object which will be passed to all the functions listed here.</li>
<li>Initialize the operation object with one of the methods described in the documentation for <a class="reference internal" href="#c.psa_mac_operation_t" title="psa_mac_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code></a>, e.g. PSA_MAC_OPERATION_INIT.</li>
<li>Call <a class="reference internal" href="#c.psa_mac_verify_setup" title="psa_mac_verify_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_setup()</span></code></a> to specify the algorithm and key.</li>
<li>Call <a class="reference internal" href="#c.psa_mac_update" title="psa_mac_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_update()</span></code></a> zero, one or more times, passing a fragment of the message each time. The MAC that is calculated is the MAC of the concatenation of these messages in order.</li>
<li>At the end of the message, call <a class="reference internal" href="#c.psa_mac_verify_finish" title="psa_mac_verify_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_finish()</span></code></a> to finish calculating the actual MAC of the message and verify it against the expected value.</li>
</ol>
<p>The application may call <a class="reference internal" href="#c.psa_mac_abort" title="psa_mac_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_abort()</span></code></a> at any time after the operation has been initialized.</p>
<p>After a successful call to <a class="reference internal" href="#c.psa_mac_verify_setup" title="psa_mac_verify_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_setup()</span></code></a>, the application must eventually terminate the operation through one of the following methods:</p>
<ul class="simple">
<li>A failed call to <a class="reference internal" href="#c.psa_mac_update" title="psa_mac_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_update()</span></code></a>.</li>
<li>A call to <a class="reference internal" href="#c.psa_mac_verify_finish" title="psa_mac_verify_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_finish()</span></code></a> or <a class="reference internal" href="#c.psa_mac_abort" title="psa_mac_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_abort()</span></code></a>.</li>
</ul>
</div>
<div class="section" id="psa_mac_update">
<span id="c.psa_mac_update"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_update</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_update</span><span class="p">(</span><span class="n">psa_mac_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                            <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span>
                            <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active MAC operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt>
<dd>Buffer containing the message fragment to add to the MAC calculation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, or already completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Add a message fragment to a multipart MAC operation.</p>
<p>The application must call <a class="reference internal" href="#c.psa_mac_sign_setup" title="psa_mac_sign_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_setup()</span></code></a> or <a class="reference internal" href="#c.psa_mac_verify_setup" title="psa_mac_verify_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_setup()</span></code></a> before calling this function.</p>
<p>If this function returns an error status, the operation becomes inactive.</p>
</div>
<div class="section" id="psa_mac_sign_finish">
<span id="c.psa_mac_sign_finish"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_sign_finish</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_sign_finish</span><span class="p">(</span><span class="n">psa_mac_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                 <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">mac</span><span class="p">,</span>
                                 <span class="kt">size_t</span> <span class="n">mac_size</span><span class="p">,</span>
                                 <span class="kt">size_t</span> <span class="o">*</span> <span class="n">mac_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active MAC operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">mac</span></code></dt>
<dd>Buffer where the MAC value is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">mac_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">mac</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">mac_length</span></code></dt>
<dd>On success, the number of bytes that make up the MAC value. This is always <a class="reference internal" href="#c.PSA_MAC_FINAL_SIZE" title="PSA_MAC_FINAL_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_MAC_FINAL_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">key_type</span></code>, <code class="docutils literal notranslate"><span class="pre">key_bits</span></code>, <code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">key_type</span></code> and <code class="docutils literal notranslate"><span class="pre">key_bits</span></code> are the type and bit-size respectively of the key and <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the MAC algorithm that is calculated.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, or already completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of the <code class="docutils literal notranslate"><span class="pre">mac</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_MAC_FINAL_SIZE" title="PSA_MAC_FINAL_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_MAC_FINAL_SIZE()</span></code></a>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Finish the calculation of the MAC of a message.</p>
<p>The application must call <a class="reference internal" href="#c.psa_mac_sign_setup" title="psa_mac_sign_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_setup()</span></code></a> before calling this function. This function calculates the MAC of the message formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_mac_update" title="psa_mac_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_update()</span></code></a>.</p>
<p>When this function returns, the operation becomes inactive.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">Applications should not call this function if they expect a specific value for the MAC. Call <a class="reference internal" href="#c.psa_mac_verify_finish" title="psa_mac_verify_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_finish()</span></code></a> instead. Beware that comparing integrity or authenticity data such as MAC values with a function such as <code class="docutils literal notranslate"><span class="pre">memcmp</span></code> is risky because the time taken by the comparison may leak information about the MAC value which could allow an attacker to guess a valid MAC and thereby bypass security controls.</p>
</div>
</div>
<div class="section" id="psa_mac_verify_finish">
<span id="c.psa_mac_verify_finish"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_verify_finish</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_verify_finish</span><span class="p">(</span><span class="n">psa_mac_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                   <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">mac</span><span class="p">,</span>
                                   <span class="kt">size_t</span> <span class="n">mac_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active MAC operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">mac</span></code></dt>
<dd>Buffer containing the expected MAC value.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">mac_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">mac</span></code> buffer in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The expected MAC is identical to the actual MAC of the message.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_SIGNATURE" title="PSA_ERROR_INVALID_SIGNATURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The MAC of the message was calculated successfully, but it differs from the expected MAC.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, or already completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Finish the calculation of the MAC of a message and compare it with an expected value.</p>
<p>The application must call <a class="reference internal" href="#c.psa_mac_verify_setup" title="psa_mac_verify_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_setup()</span></code></a> before calling this function. This function calculates the MAC of the message formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_mac_update" title="psa_mac_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_update()</span></code></a>. It then compares the calculated MAC with the expected MAC passed as a parameter to this function.</p>
<p>When this function returns, the operation becomes inactive.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Implementations shall make the best effort to ensure that the comparison between the actual MAC and the expected MAC is performed in constant time.</p>
</div>
</div>
<div class="section" id="psa_mac_abort">
<span id="c.psa_mac_abort"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_mac_abort</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_mac_abort</span><span class="p">(</span><span class="n">psa_mac_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Initialized MAC operation.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">operation</span></code> is not an active MAC operation.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Abort a MAC operation.</p>
<p>Aborting an operation frees all associated resources except for the <code class="docutils literal notranslate"><span class="pre">operation</span></code> structure itself. Once aborted, the operation object can be reused for another operation by calling <a class="reference internal" href="#c.psa_mac_sign_setup" title="psa_mac_sign_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_setup()</span></code></a> or <a class="reference internal" href="#c.psa_mac_verify_setup" title="psa_mac_verify_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_setup()</span></code></a> again.</p>
<p>You may call this function any time after the operation object has been initialized by any of the following methods:</p>
<ul class="simple">
<li>A call to <a class="reference internal" href="#c.psa_mac_sign_setup" title="psa_mac_sign_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_setup()</span></code></a> or <a class="reference internal" href="#c.psa_mac_verify_setup" title="psa_mac_verify_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_setup()</span></code></a>, whether it succeeds or not.</li>
<li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to all-bits-zero.</li>
<li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to logical zeros, e.g. <code class="docutils literal notranslate"><span class="pre">psa_mac_operation_t</span> <span class="pre">operation</span> <span class="pre">=</span> <span class="pre">{0}</span></code>.</li>
</ul>
<p>In particular, calling <a class="reference internal" href="#c.psa_mac_abort" title="psa_mac_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_abort()</span></code></a> after the operation has been terminated by a call to <a class="reference internal" href="#c.psa_mac_abort" title="psa_mac_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_abort()</span></code></a>, <a class="reference internal" href="#c.psa_mac_sign_finish" title="psa_mac_sign_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_finish()</span></code></a> or <a class="reference internal" href="#c.psa_mac_verify_finish" title="psa_mac_verify_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_finish()</span></code></a> is safe and has no effect.</p>
</div>
</div>
<div class="section" id="symmetric-ciphers">
<h1>Symmetric ciphers</h1>
<div class="section" id="psa_cipher_operation_t">
<span id="c.psa_cipher_operation_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">psa_cipher_operation_s</span> <span class="n">psa_cipher_operation_t</span><span class="p">;</span>
</pre></div>
</div>
<p>The type of the state data structure for multipart cipher operations.</p>
<p>Before calling any function on a cipher operation object, the application must initialize it by any of the following means:</p>
<ul>
<li><p class="first">Set the structure to all-bits-zero, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_cipher_operation_t</span> <span class="n">operation</span><span class="p">;</span>
<span class="n">memset</span><span class="p">(</span><span class="o">&amp;</span><span class="n">operation</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">operation</span><span class="p">));</span>
</pre></div>
</div>
</li>
<li><p class="first">Initialize the structure to logical zero values, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_cipher_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">};</span>
</pre></div>
</div>
</li>
<li><p class="first">Initialize the structure to the initializer <a class="reference internal" href="#c.PSA_CIPHER_OPERATION_INIT" title="PSA_CIPHER_OPERATION_INIT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_CIPHER_OPERATION_INIT</span></code></a>, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_cipher_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="n">PSA_CIPHER_OPERATION_INIT</span><span class="p">;</span>
</pre></div>
</div>
</li>
<li><p class="first">Assign the result of the function <a class="reference internal" href="#c.psa_cipher_operation_init" title="psa_cipher_operation_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_operation_init()</span></code></a> to the structure, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_cipher_operation_t</span> <span class="n">operation</span><span class="p">;</span>
<span class="n">operation</span> <span class="o">=</span> <span class="n">psa_cipher_operation_init</span><span class="p">();</span>
</pre></div>
</div>
</li>
</ul>
<p>This is an implementation-defined <code class="docutils literal notranslate"><span class="pre">struct</span></code>. Applications should not make any assumptions about the content of this structure except as directed by the documentation of a specific implementation.</p>
</div>
<div class="section" id="PSA_CIPHER_OPERATION_INIT">
<span id="c.PSA_CIPHER_OPERATION_INIT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_CIPHER_OPERATION_INIT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_CIPHER_OPERATION_INIT  {0}</span>
</pre></div>
</div>
<p>This macro returns a suitable initializer for a cipher operation object of type <a class="reference internal" href="#c.psa_cipher_operation_t" title="psa_cipher_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code></a>.</p>
</div>
<div class="section" id="psa_cipher_encrypt">
<span id="c.psa_cipher_encrypt"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_encrypt</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_encrypt</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                                <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span>
                                <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span>
                                <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span>
                                <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span>
                                <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span>
                                <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The cipher algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_CIPHER" title="PSA_ALG_IS_CIPHER"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_CIPHER</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt>
<dd>Buffer containing the message to encrypt.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt>
<dd>Buffer where the output is to be written. The output contains the IV followed by the ciphertext proper.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt>
<dd>On success, the number of bytes that make up the output.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a cipher algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Encrypt a message using a symmetric cipher.</p>
<p>This function encrypts a message with a random IV (initialization vector).</p>
</div>
<div class="section" id="psa_cipher_decrypt">
<span id="c.psa_cipher_decrypt"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_decrypt</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_decrypt</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                                <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span>
                                <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span>
                                <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span>
                                <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span>
                                <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span>
                                <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The cipher algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_CIPHER" title="PSA_ALG_IS_CIPHER"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_CIPHER</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt>
<dd>Buffer containing the message to decrypt. This consists of the IV followed by the ciphertext proper.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt>
<dd>Buffer where the plaintext is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt>
<dd>On success, the number of bytes that make up the output.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a cipher algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Decrypt a message using a symmetric cipher.</p>
<p>This function decrypts a message encrypted with a symmetric cipher.</p>
</div>
<div class="section" id="psa_cipher_operation_init">
<span id="c.psa_cipher_operation_init"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_operation_init</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_cipher_operation_t</span> <span class="nf">psa_cipher_operation_init</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_cipher_operation_t" title="psa_cipher_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Return an initial value for a cipher operation object.</p>
</div>
<div class="section" id="psa_cipher_encrypt_setup">
<span id="c.psa_cipher_encrypt_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_encrypt_setup</span><span class="p">(</span><span class="n">psa_cipher_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                      <span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                                      <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The operation object to set up. It must have been initialized as per the documentation for <a class="reference internal" href="#c.psa_cipher_operation_t" title="psa_cipher_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code></a> and not yet in use.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The cipher algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_CIPHER" title="PSA_ALG_IS_CIPHER"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_CIPHER</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a cipher algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (already set up and not subsequently completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Set the key for a multipart symmetric encryption operation.</p>
<p>The sequence of operations to encrypt a message with a symmetric cipher is as follows:</p>
<ol class="arabic simple">
<li>Allocate an operation object which will be passed to all the functions listed here.</li>
<li>Initialize the operation object with one of the methods described in the documentation for <a class="reference internal" href="#c.psa_cipher_operation_t" title="psa_cipher_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code></a>, e.g. PSA_CIPHER_OPERATION_INIT.</li>
<li>Call <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a> to specify the algorithm and key.</li>
<li>Call either <a class="reference internal" href="#c.psa_cipher_generate_iv" title="psa_cipher_generate_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_generate_iv()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_set_iv" title="psa_cipher_set_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_set_iv()</span></code></a> to generate or set the IV (initialization vector). You should use <a class="reference internal" href="#c.psa_cipher_generate_iv" title="psa_cipher_generate_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_generate_iv()</span></code></a> unless the protocol you are implementing requires a specific IV value.</li>
<li>Call <a class="reference internal" href="#c.psa_cipher_update" title="psa_cipher_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_update()</span></code></a> zero, one or more times, passing a fragment of the message each time.</li>
<li>Call <a class="reference internal" href="#c.psa_cipher_finish" title="psa_cipher_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_finish()</span></code></a>.</li>
</ol>
<p>The application may call <a class="reference internal" href="#c.psa_cipher_abort" title="psa_cipher_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_abort()</span></code></a> at any time after the operation has been initialized.</p>
<p>After a successful call to <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a>, the application must eventually terminate the operation. The following events terminate an operation:</p>
<ul class="simple">
<li>A failed call to any of the <code class="docutils literal notranslate"><span class="pre">psa_cipher_xxx</span></code> functions.</li>
<li>A call to <a class="reference internal" href="#c.psa_cipher_finish" title="psa_cipher_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_finish()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_abort" title="psa_cipher_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_abort()</span></code></a>.</li>
</ul>
</div>
<div class="section" id="psa_cipher_decrypt_setup">
<span id="c.psa_cipher_decrypt_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_decrypt_setup</span><span class="p">(</span><span class="n">psa_cipher_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                      <span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                                      <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The operation object to set up. It must have been initialized as per the documentation for <a class="reference internal" href="#c.psa_cipher_operation_t" title="psa_cipher_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code></a> and not yet in use.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The cipher algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_CIPHER" title="PSA_ALG_IS_CIPHER"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_CIPHER</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a cipher algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (already set up and not subsequently completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Set the key for a multipart symmetric decryption operation.</p>
<p>The sequence of operations to decrypt a message with a symmetric cipher is as follows:</p>
<ol class="arabic simple">
<li>Allocate an operation object which will be passed to all the functions listed here.</li>
<li>Initialize the operation object with one of the methods described in the documentation for <a class="reference internal" href="#c.psa_cipher_operation_t" title="psa_cipher_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code></a>, e.g. PSA_CIPHER_OPERATION_INIT.</li>
<li>Call <a class="reference internal" href="#c.psa_cipher_decrypt_setup" title="psa_cipher_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup()</span></code></a> to specify the algorithm and key.</li>
<li>Call <a class="reference internal" href="#c.psa_cipher_set_iv" title="psa_cipher_set_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_set_iv()</span></code></a> with the IV (initialization vector) for the decryption. If the IV is prepended to the ciphertext, you can call <a class="reference internal" href="#c.psa_cipher_update" title="psa_cipher_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_update()</span></code></a> on a buffer containing the IV followed by the beginning of the message.</li>
<li>Call <a class="reference internal" href="#c.psa_cipher_update" title="psa_cipher_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_update()</span></code></a> zero, one or more times, passing a fragment of the message each time.</li>
<li>Call <a class="reference internal" href="#c.psa_cipher_finish" title="psa_cipher_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_finish()</span></code></a>.</li>
</ol>
<p>The application may call <a class="reference internal" href="#c.psa_cipher_abort" title="psa_cipher_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_abort()</span></code></a> at any time after the operation has been initialized.</p>
<p>After a successful call to <a class="reference internal" href="#c.psa_cipher_decrypt_setup" title="psa_cipher_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup()</span></code></a>, the application must eventually terminate the operation. The following events terminate an operation:</p>
<ul class="simple">
<li>A failed call to any of the <code class="docutils literal notranslate"><span class="pre">psa_cipher_xxx</span></code> functions.</li>
<li>A call to <a class="reference internal" href="#c.psa_cipher_finish" title="psa_cipher_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_finish()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_abort" title="psa_cipher_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_abort()</span></code></a>.</li>
</ul>
</div>
<div class="section" id="psa_cipher_generate_iv">
<span id="c.psa_cipher_generate_iv"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_generate_iv</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_generate_iv</span><span class="p">(</span><span class="n">psa_cipher_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                    <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">iv</span><span class="p">,</span>
                                    <span class="kt">size_t</span> <span class="n">iv_size</span><span class="p">,</span>
                                    <span class="kt">size_t</span> <span class="o">*</span> <span class="n">iv_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active cipher operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">iv</span></code></dt>
<dd>Buffer where the generated IV is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">iv_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">iv</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">iv_length</span></code></dt>
<dd>On success, the number of bytes of the generated IV.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, or IV already set).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of the <code class="docutils literal notranslate"><span class="pre">iv</span></code> buffer is too small.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Generate an IV for a symmetric encryption operation.</p>
<p>This function generates a random IV (initialization vector), nonce or initial counter value for the encryption operation as appropriate for the chosen algorithm, key type and key size.</p>
<p>The application must call <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a> before calling this function.</p>
<p>If this function returns an error status, the operation becomes inactive.</p>
</div>
<div class="section" id="psa_cipher_set_iv">
<span id="c.psa_cipher_set_iv"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_set_iv</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_set_iv</span><span class="p">(</span><span class="n">psa_cipher_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                               <span class="k">const</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">iv</span><span class="p">,</span>
                               <span class="kt">size_t</span> <span class="n">iv_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active cipher operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">iv</span></code></dt>
<dd>Buffer containing the IV to use.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">iv_length</span></code></dt>
<dd>Size of the IV in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, or IV already set).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of <code class="docutils literal notranslate"><span class="pre">iv</span></code> is not acceptable for the chosen algorithm, or the chosen algorithm does not use an IV.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Set the IV for a symmetric encryption or decryption operation.</p>
<p>This function sets the IV (initialization vector), nonce or initial counter value for the encryption or decryption operation.</p>
<p>The application must call <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a> before calling this function.</p>
<p>If this function returns an error status, the operation becomes inactive.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">When encrypting, applications should use <a class="reference internal" href="#c.psa_cipher_generate_iv" title="psa_cipher_generate_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_generate_iv()</span></code></a> instead of this function, unless implementing a protocol that requires a non-random IV.</p>
</div>
</div>
<div class="section" id="psa_cipher_update">
<span id="c.psa_cipher_update"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_update</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_update</span><span class="p">(</span><span class="n">psa_cipher_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                               <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span>
                               <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span>
                               <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span>
                               <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span>
                               <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active cipher operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt>
<dd>Buffer containing the message fragment to encrypt or decrypt.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt>
<dd>Buffer where the output is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt>
<dd>On success, the number of bytes that make up the returned output.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, IV required but not set, or already completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer is too small.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Encrypt or decrypt a message fragment in an active cipher operation.</p>
<p>Before calling this function, you must:</p>
<ol class="arabic simple">
<li>Call either <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_decrypt_setup" title="psa_cipher_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup()</span></code></a>. The choice of setup function determines whether this function encrypts or decrypts its input.</li>
<li>If the algorithm requires an IV, call <a class="reference internal" href="#c.psa_cipher_generate_iv" title="psa_cipher_generate_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_generate_iv()</span></code></a> (recommended when encrypting) or <a class="reference internal" href="#c.psa_cipher_set_iv" title="psa_cipher_set_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_set_iv()</span></code></a>.</li>
</ol>
<p>If this function returns an error status, the operation becomes inactive.</p>
</div>
<div class="section" id="psa_cipher_finish">
<span id="c.psa_cipher_finish"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_finish</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_finish</span><span class="p">(</span><span class="n">psa_cipher_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                               <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span>
                               <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span>
                               <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active cipher operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt>
<dd>Buffer where the output is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt>
<dd>On success, the number of bytes that make up the returned output.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, IV required but not set, or already completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer is too small.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Finish encrypting or decrypting a message in a cipher operation.</p>
<p>The application must call <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_decrypt_setup" title="psa_cipher_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup()</span></code></a> before calling this function. The choice of setup function determines whether this function encrypts or decrypts its input.</p>
<p>This function finishes the encryption or decryption of the message formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_cipher_update" title="psa_cipher_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_update()</span></code></a>.</p>
<p>When this function returns, the operation becomes inactive.</p>
</div>
<div class="section" id="psa_cipher_abort">
<span id="c.psa_cipher_abort"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_cipher_abort</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_cipher_abort</span><span class="p">(</span><span class="n">psa_cipher_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Initialized cipher operation.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">operation</span></code> is not an active cipher operation.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Abort a cipher operation.</p>
<p>Aborting an operation frees all associated resources except for the <code class="docutils literal notranslate"><span class="pre">operation</span></code> structure itself. Once aborted, the operation object can be reused for another operation by calling <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_decrypt_setup" title="psa_cipher_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup()</span></code></a> again.</p>
<p>You may call this function any time after the operation object has been initialized by any of the following methods:</p>
<ul class="simple">
<li>A call to <a class="reference internal" href="#c.psa_cipher_encrypt_setup" title="psa_cipher_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_decrypt_setup" title="psa_cipher_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup()</span></code></a>, whether it succeeds or not.</li>
<li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to all-bits-zero.</li>
<li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to logical zeros, e.g. <code class="docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span> <span class="pre">operation</span> <span class="pre">=</span> <span class="pre">{0}</span></code>.</li>
</ul>
<p>In particular, calling <a class="reference internal" href="#c.psa_cipher_abort" title="psa_cipher_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_abort()</span></code></a> after the operation has been terminated by a call to <a class="reference internal" href="#c.psa_cipher_abort" title="psa_cipher_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_abort()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_finish" title="psa_cipher_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_finish()</span></code></a> is safe and has no effect.</p>
</div>
</div>
<div class="section" id="authenticated-encryption-with-associated-data-aead">
<h1>Authenticated encryption with associated data (AEAD)</h1>
<div class="section" id="psa_aead_operation_t">
<span id="c.psa_aead_operation_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">psa_aead_operation_s</span> <span class="n">psa_aead_operation_t</span><span class="p">;</span>
</pre></div>
</div>
<p>The type of the state data structure for multipart AEAD operations.</p>
<p>Before calling any function on an AEAD operation object, the application must initialize it by any of the following means:</p>
<ul>
<li><p class="first">Set the structure to all-bits-zero, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_aead_operation_t</span> <span class="n">operation</span><span class="p">;</span>
<span class="n">memset</span><span class="p">(</span><span class="o">&amp;</span><span class="n">operation</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">operation</span><span class="p">));</span>
</pre></div>
</div>
</li>
<li><p class="first">Initialize the structure to logical zero values, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_aead_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">};</span>
</pre></div>
</div>
</li>
<li><p class="first">Initialize the structure to the initializer <a class="reference internal" href="#c.PSA_AEAD_OPERATION_INIT" title="PSA_AEAD_OPERATION_INIT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_OPERATION_INIT</span></code></a>, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_aead_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="n">PSA_AEAD_OPERATION_INIT</span><span class="p">;</span>
</pre></div>
</div>
</li>
<li><p class="first">Assign the result of the function <a class="reference internal" href="#c.psa_aead_operation_init" title="psa_aead_operation_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_operation_init()</span></code></a> to the structure, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_aead_operation_t</span> <span class="n">operation</span><span class="p">;</span>
<span class="n">operation</span> <span class="o">=</span> <span class="n">psa_aead_operation_init</span><span class="p">();</span>
</pre></div>
</div>
</li>
</ul>
<p>This is an implementation-defined <code class="docutils literal notranslate"><span class="pre">struct</span></code>. Applications should not make any assumptions about the content of this structure except as directed by the documentation of a specific implementation.</p>
</div>
<div class="section" id="PSA_AEAD_OPERATION_INIT">
<span id="c.PSA_AEAD_OPERATION_INIT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_OPERATION_INIT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_OPERATION_INIT  {0}</span>
</pre></div>
</div>
<p>This macro returns a suitable initializer for an AEAD operation object of type <a class="reference internal" href="#c.psa_aead_operation_t" title="psa_aead_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code></a>.</p>
</div>
<div class="section" id="psa_aead_encrypt">
<span id="c.psa_aead_encrypt"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_encrypt</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_encrypt</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                              <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span>
                              <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">nonce</span><span class="p">,</span>
                              <span class="kt">size_t</span> <span class="n">nonce_length</span><span class="p">,</span>
                              <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">additional_data</span><span class="p">,</span>
                              <span class="kt">size_t</span> <span class="n">additional_data_length</span><span class="p">,</span>
                              <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">plaintext</span><span class="p">,</span>
                              <span class="kt">size_t</span> <span class="n">plaintext_length</span><span class="p">,</span>
                              <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">ciphertext</span><span class="p">,</span>
                              <span class="kt">size_t</span> <span class="n">ciphertext_size</span><span class="p">,</span>
                              <span class="kt">size_t</span> <span class="o">*</span> <span class="n">ciphertext_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The AEAD algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">nonce</span></code></dt>
<dd>Nonce or IV to use.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">nonce_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">nonce</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">additional_data</span></code></dt>
<dd>Additional data that will be authenticated but not encrypted.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">additional_data_length</span></code></dt>
<dd>Size of <code class="docutils literal notranslate"><span class="pre">additional_data</span></code> in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">plaintext</span></code></dt>
<dd>Data that will be authenticated and encrypted.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">plaintext_length</span></code></dt>
<dd>Size of <code class="docutils literal notranslate"><span class="pre">plaintext</span></code> in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code></dt>
<dd>Output buffer for the authenticated and encrypted data. The additional data is not part of this output. For algorithms where the encrypted data and the authentication tag are defined as separate outputs, the authentication tag is appended to the encrypted data.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">ciphertext_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code> buffer in bytes. This must be at least <a class="reference internal" href="#c.PSA_AEAD_ENCRYPT_OUTPUT_SIZE" title="PSA_AEAD_ENCRYPT_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_ENCRYPT_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>, <code class="docutils literal notranslate"><span class="pre">plaintext_length</span></code>).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">ciphertext_length</span></code></dt>
<dd>On success, the size of the output in the <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code> buffer.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not an AEAD algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Process an authenticated encryption operation.</p>
</div>
<div class="section" id="psa_aead_decrypt">
<span id="c.psa_aead_decrypt"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_decrypt</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_decrypt</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                              <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span>
                              <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">nonce</span><span class="p">,</span>
                              <span class="kt">size_t</span> <span class="n">nonce_length</span><span class="p">,</span>
                              <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">additional_data</span><span class="p">,</span>
                              <span class="kt">size_t</span> <span class="n">additional_data_length</span><span class="p">,</span>
                              <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">ciphertext</span><span class="p">,</span>
                              <span class="kt">size_t</span> <span class="n">ciphertext_length</span><span class="p">,</span>
                              <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">plaintext</span><span class="p">,</span>
                              <span class="kt">size_t</span> <span class="n">plaintext_size</span><span class="p">,</span>
                              <span class="kt">size_t</span> <span class="o">*</span> <span class="n">plaintext_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The AEAD algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">nonce</span></code></dt>
<dd>Nonce or IV to use.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">nonce_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">nonce</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">additional_data</span></code></dt>
<dd>Additional data that has been authenticated but not encrypted.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">additional_data_length</span></code></dt>
<dd>Size of <code class="docutils literal notranslate"><span class="pre">additional_data</span></code> in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code></dt>
<dd>Data that has been authenticated and encrypted. For algorithms where the encrypted data and the authentication tag are defined as separate inputs, the buffer must contain the encrypted data followed by the authentication tag.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">ciphertext_length</span></code></dt>
<dd>Size of <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code> in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">plaintext</span></code></dt>
<dd>Output buffer for the decrypted data.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">plaintext_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">plaintext</span></code> buffer in bytes. This must be at least <a class="reference internal" href="#c.PSA_AEAD_DECRYPT_OUTPUT_SIZE" title="PSA_AEAD_DECRYPT_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_DECRYPT_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>, <code class="docutils literal notranslate"><span class="pre">ciphertext_length</span></code>).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">plaintext_length</span></code></dt>
<dd>On success, the size of the output in the <code class="docutils literal notranslate"><span class="pre">plaintext</span></code> buffer.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_SIGNATURE" title="PSA_ERROR_INVALID_SIGNATURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The ciphertext is not authentic.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not an AEAD algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Process an authenticated decryption operation.</p>
</div>
<div class="section" id="psa_aead_operation_init">
<span id="c.psa_aead_operation_init"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_operation_init</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_aead_operation_t</span> <span class="nf">psa_aead_operation_init</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_aead_operation_t" title="psa_aead_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Return an initial value for an AEAD operation object.</p>
</div>
<div class="section" id="psa_aead_encrypt_setup">
<span id="c.psa_aead_encrypt_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_encrypt_setup</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                    <span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                                    <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The operation object to set up. It must have been initialized as per the documentation for <a class="reference internal" href="#c.psa_aead_operation_t" title="psa_aead_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code></a> and not yet in use.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The AEAD algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not an AEAD algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Set the key for a multipart authenticated encryption operation.</p>
<p>The sequence of operations to encrypt a message with authentication is as follows:</p>
<ol class="arabic simple">
<li>Allocate an operation object which will be passed to all the functions listed here.</li>
<li>Initialize the operation object with one of the methods described in the documentation for <a class="reference internal" href="#c.psa_aead_operation_t" title="psa_aead_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code></a>, e.g. PSA_AEAD_OPERATION_INIT.</li>
<li>Call <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a> to specify the algorithm and key.</li>
<li>If needed, call <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a> to specify the length of the inputs to the subsequent calls to <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> and <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>. See the documentation of <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a> for details.</li>
<li>Call either <a class="reference internal" href="#c.psa_aead_generate_nonce" title="psa_aead_generate_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_generate_nonce()</span></code></a> or <a class="reference internal" href="#c.psa_aead_set_nonce" title="psa_aead_set_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_nonce()</span></code></a> to generate or set the nonce. You should use <a class="reference internal" href="#c.psa_aead_generate_nonce" title="psa_aead_generate_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_generate_nonce()</span></code></a> unless the protocol you are implementing requires a specific nonce value.</li>
<li>Call <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> zero, one or more times, passing a fragment of the non-encrypted additional authenticated data each time.</li>
<li>Call <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> zero, one or more times, passing a fragment of the message to encrypt each time.</li>
<li>Call <a class="reference internal" href="#c.psa_aead_finish" title="psa_aead_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_finish()</span></code></a>.</li>
</ol>
<p>The application may call <a class="reference internal" href="#c.psa_aead_abort" title="psa_aead_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_abort()</span></code></a> at any time after the operation has been initialized.</p>
<p>After a successful call to <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a>, the application must eventually terminate the operation. The following events terminate an operation:</p>
<ul class="simple">
<li>A failed call to any of the <code class="docutils literal notranslate"><span class="pre">psa_aead_xxx</span></code> functions.</li>
<li>A call to <a class="reference internal" href="#c.psa_aead_finish" title="psa_aead_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_finish()</span></code></a>, <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> or <a class="reference internal" href="#c.psa_aead_abort" title="psa_aead_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_abort()</span></code></a>.</li>
</ul>
</div>
<div class="section" id="psa_aead_decrypt_setup">
<span id="c.psa_aead_decrypt_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_decrypt_setup</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                    <span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                                    <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The operation object to set up. It must have been initialized as per the documentation for <a class="reference internal" href="#c.psa_aead_operation_t" title="psa_aead_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code></a> and not yet in use.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation. It must remain valid until the operation terminates.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The AEAD algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">handle</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not an AEAD algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Set the key for a multipart authenticated decryption operation.</p>
<p>The sequence of operations to decrypt a message with authentication is as follows:</p>
<ol class="arabic simple">
<li>Allocate an operation object which will be passed to all the functions listed here.</li>
<li>Initialize the operation object with one of the methods described in the documentation for <a class="reference internal" href="#c.psa_aead_operation_t" title="psa_aead_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code></a>, e.g. PSA_AEAD_OPERATION_INIT.</li>
<li>Call <a class="reference internal" href="#c.psa_aead_decrypt_setup" title="psa_aead_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup()</span></code></a> to specify the algorithm and key.</li>
<li>If needed, call <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a> to specify the length of the inputs to the subsequent calls to <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> and <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>. See the documentation of <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a> for details.</li>
<li>Call <a class="reference internal" href="#c.psa_aead_set_nonce" title="psa_aead_set_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_nonce()</span></code></a> with the nonce for the decryption.</li>
<li>Call <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> zero, one or more times, passing a fragment of the non-encrypted additional authenticated data each time.</li>
<li>Call <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> zero, one or more times, passing a fragment of the ciphertext to decrypt each time.</li>
<li>Call <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a>.</li>
</ol>
<p>The application may call <a class="reference internal" href="#c.psa_aead_abort" title="psa_aead_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_abort()</span></code></a> at any time after the operation has been initialized.</p>
<p>After a successful call to <a class="reference internal" href="#c.psa_aead_decrypt_setup" title="psa_aead_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup()</span></code></a>, the application must eventually terminate the operation. The following events terminate an operation:</p>
<ul class="simple">
<li>A failed call to any of the <code class="docutils literal notranslate"><span class="pre">psa_aead_xxx</span></code> functions.</li>
<li>A call to <a class="reference internal" href="#c.psa_aead_finish" title="psa_aead_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_finish()</span></code></a>, <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> or <a class="reference internal" href="#c.psa_aead_abort" title="psa_aead_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_abort()</span></code></a>.</li>
</ul>
</div>
<div class="section" id="psa_aead_generate_nonce">
<span id="c.psa_aead_generate_nonce"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_generate_nonce</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_generate_nonce</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                     <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">nonce</span><span class="p">,</span>
                                     <span class="kt">size_t</span> <span class="n">nonce_size</span><span class="p">,</span>
                                     <span class="kt">size_t</span> <span class="o">*</span> <span class="n">nonce_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active AEAD operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">nonce</span></code></dt>
<dd>Buffer where the generated nonce is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">nonce_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">nonce</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">nonce_length</span></code></dt>
<dd>On success, the number of bytes of the generated nonce.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, or nonce already set).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of the <code class="docutils literal notranslate"><span class="pre">nonce</span></code> buffer is too small.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Generate a random nonce for an authenticated encryption operation.</p>
<p>This function generates a random nonce for the authenticated encryption operation with an appropriate size for the chosen algorithm, key type and key size.</p>
<p>The application must call <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a> before calling this function.</p>
<p>If this function returns an error status, the operation becomes inactive.</p>
</div>
<div class="section" id="psa_aead_set_nonce">
<span id="c.psa_aead_set_nonce"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_set_nonce</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_set_nonce</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                <span class="k">const</span> <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">nonce</span><span class="p">,</span>
                                <span class="kt">size_t</span> <span class="n">nonce_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active AEAD operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">nonce</span></code></dt>
<dd>Buffer containing the nonce to use.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">nonce_length</span></code></dt>
<dd>Size of the nonce in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, or nonce already set).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of <code class="docutils literal notranslate"><span class="pre">nonce</span></code> is not acceptable for the chosen algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Set the nonce for an authenticated encryption or decryption operation.</p>
<p>This function sets the nonce for the authenticated encryption or decryption operation.</p>
<p>The application must call <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a> before calling this function.</p>
<p>If this function returns an error status, the operation becomes inactive.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">When encrypting, applications should use <a class="reference internal" href="#c.psa_aead_generate_nonce" title="psa_aead_generate_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_generate_nonce()</span></code></a> instead of this function, unless implementing a protocol that requires a non-random IV.</p>
</div>
</div>
<div class="section" id="psa_aead_set_lengths">
<span id="c.psa_aead_set_lengths"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_set_lengths</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_set_lengths</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                  <span class="kt">size_t</span> <span class="n">ad_length</span><span class="p">,</span>
                                  <span class="kt">size_t</span> <span class="n">plaintext_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active AEAD operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">ad_length</span></code></dt>
<dd>Size of the non-encrypted additional authenticated data in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">plaintext_length</span></code></dt>
<dd>Size of the plaintext to encrypt in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, already completed, or <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> or <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> already called).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>At least one of the lengths is not acceptable for the chosen algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Declare the lengths of the message and additional data for AEAD.</p>
<p>The application must call this function before calling <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> or <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> if the algorithm for the operation requires it. If the algorithm does not require it, calling this function is optional, but if this function is called then the implementation must enforce the lengths.</p>
<p>You may call this function before or after setting the nonce with <a class="reference internal" href="#c.psa_aead_set_nonce" title="psa_aead_set_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_nonce()</span></code></a> or <a class="reference internal" href="#c.psa_aead_generate_nonce" title="psa_aead_generate_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_generate_nonce()</span></code></a>.</p>
<ul class="simple">
<li>For <a class="reference internal" href="#c.PSA_ALG_CCM" title="PSA_ALG_CCM"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_CCM</span></code></a>, calling this function is required.</li>
<li>For the other AEAD algorithms defined in this specification, calling this function is not required.</li>
<li>For vendor-defined algorithm, refer to the vendor documentation.</li>
</ul>
</div>
<div class="section" id="psa_aead_update_ad">
<span id="c.psa_aead_update_ad"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_update_ad</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_update_ad</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span>
                                <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active AEAD operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt>
<dd>Buffer containing the fragment of additional data.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, nonce not set, <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> already called, or operation already completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The total input length overflows the additional data length that was previously specified with <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Pass additional data to an active AEAD operation.</p>
<p>Additional data is authenticated, but not encrypted.</p>
<p>You may call this function multiple times to pass successive fragments of the additional data. You may not call this function after passing data to encrypt or decrypt with <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>.</p>
<p>Before calling this function, you must:</p>
<ol class="arabic simple">
<li>Call either <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_aead_decrypt_setup" title="psa_aead_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup()</span></code></a>.</li>
<li>Set the nonce with <a class="reference internal" href="#c.psa_aead_generate_nonce" title="psa_aead_generate_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_generate_nonce()</span></code></a> or <a class="reference internal" href="#c.psa_aead_set_nonce" title="psa_aead_set_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_nonce()</span></code></a>.</li>
</ol>
<p>If this function returns an error status, the operation becomes inactive.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">When decrypting, until <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> has returned <a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a>, there is no guarantee that the input is valid. Therefore, until you have called <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> and it has returned <a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a>, treat the input as untrusted and prepare to undo any action that depends on the input if <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> returns an error status.</p>
</div>
</div>
<div class="section" id="psa_aead_update">
<span id="c.psa_aead_update"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_update</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_update</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                             <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span>
                             <span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active AEAD operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt>
<dd>Buffer containing the message fragment to encrypt or decrypt.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt>
<dd>Buffer where the output is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes. This must be at least <a class="reference internal" href="#c.PSA_AEAD_UPDATE_OUTPUT_SIZE" title="PSA_AEAD_UPDATE_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_UPDATE_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>, <code class="docutils literal notranslate"><span class="pre">input_length</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the algorithm that is being calculated.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt>
<dd>On success, the number of bytes that make up the returned output.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, nonce not set or already completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_AEAD_UPDATE_OUTPUT_SIZE" title="PSA_AEAD_UPDATE_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_UPDATE_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>, <code class="docutils literal notranslate"><span class="pre">input_length</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the algorithm that is being calculated.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The total length of input to <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> so far is less than the additional data length that was previously specified with <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The total input length overflows the plaintext length that was previously specified with <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Encrypt or decrypt a message fragment in an active AEAD operation.</p>
<p>Before calling this function, you must:</p>
<ol class="arabic simple">
<li>Call either <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_aead_decrypt_setup" title="psa_aead_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup()</span></code></a>. The choice of setup function determines whether this function encrypts or decrypts its input.</li>
<li>Set the nonce with <a class="reference internal" href="#c.psa_aead_generate_nonce" title="psa_aead_generate_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_generate_nonce()</span></code></a> or <a class="reference internal" href="#c.psa_aead_set_nonce" title="psa_aead_set_nonce"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_nonce()</span></code></a>.</li>
<li>Call <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> to pass all the additional data.</li>
</ol>
<p>If this function returns an error status, the operation becomes inactive.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p>When decrypting, until <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> has returned <a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a>, there is no guarantee that the input is valid. Therefore, until you have called <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> and it has returned <a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a>:</p>
<ul class="last simple">
<li>Do not use the output in any way other than storing it in a confidential location. If you take any action that depends on the tentative decrypted data, this action will need to be undone if the input turns out not to be valid. Furthermore, if an adversary can observe that this action took place (for example through timing), they may be able to use this fact as an oracle to decrypt any message encrypted with the same key.</li>
<li>In particular, do not copy the output anywhere but to a memory or storage space that you have exclusive access to.</li>
</ul>
</div>
<p>This function does not require the input to be aligned to any particular block boundary. If the implementation can only process a whole block at a time, it must consume all the input provided, but it may delay the end of the corresponding output until a subsequent call to <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>, <a class="reference internal" href="#c.psa_aead_finish" title="psa_aead_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_finish()</span></code></a> or <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> provides sufficient input. The amount of data that can be delayed in this way is bounded by <a class="reference internal" href="#c.PSA_AEAD_UPDATE_OUTPUT_SIZE" title="PSA_AEAD_UPDATE_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_UPDATE_OUTPUT_SIZE</span></code></a>.</p>
</div>
<div class="section" id="psa_aead_finish">
<span id="c.psa_aead_finish"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_finish</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_finish</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                             <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">ciphertext</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="n">ciphertext_size</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="o">*</span> <span class="n">ciphertext_length</span><span class="p">,</span>
                             <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">tag</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="n">tag_size</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="o">*</span> <span class="n">tag_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active AEAD operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code></dt>
<dd>Buffer where the last part of the ciphertext is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">ciphertext_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code> buffer in bytes. This must be at least <a class="reference internal" href="#c.PSA_AEAD_FINISH_OUTPUT_SIZE" title="PSA_AEAD_FINISH_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_FINISH_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the algorithm that is being calculated.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">ciphertext_length</span></code></dt>
<dd>On success, the number of bytes of returned ciphertext.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">tag</span></code></dt>
<dd>Buffer where the authentication tag is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">tag_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">tag</span></code> buffer in bytes. This must be at least <a class="reference internal" href="#c.PSA_AEAD_TAG_LENGTH" title="PSA_AEAD_TAG_LENGTH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_TAG_LENGTH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the algorithm that is being calculated.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">tag_length</span></code></dt>
<dd>On success, the number of bytes that make up the returned tag.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, nonce not set, decryption, or already completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of the <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code> or <code class="docutils literal notranslate"><span class="pre">tag</span></code> buffer is too small. You can determine a sufficient buffer size for <code class="docutils literal notranslate"><span class="pre">ciphertext</span></code> by calling <a class="reference internal" href="#c.PSA_AEAD_FINISH_OUTPUT_SIZE" title="PSA_AEAD_FINISH_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_FINISH_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the algorithm that is being calculated. You can determine a sufficient buffer size for <code class="docutils literal notranslate"><span class="pre">tag</span></code> by calling <a class="reference internal" href="#c.PSA_AEAD_TAG_LENGTH" title="PSA_AEAD_TAG_LENGTH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_TAG_LENGTH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The total length of input to <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> so far is less than the additional data length that was previously specified with <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The total length of input to <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> so far is less than the plaintext length that was previously specified with <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Finish encrypting a message in an AEAD operation.</p>
<p>The operation must have been set up with <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a>.</p>
<p>This function finishes the authentication of the additional data formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> with the plaintext formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>.</p>
<p>This function has two output buffers:</p>
<ul class="simple">
<li><code class="docutils literal notranslate"><span class="pre">ciphertext</span></code> contains trailing ciphertext that was buffered from preceding calls to <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>.</li>
<li><code class="docutils literal notranslate"><span class="pre">tag</span></code> contains the authentication tag. Its length is always <a class="reference internal" href="#c.PSA_AEAD_TAG_LENGTH" title="PSA_AEAD_TAG_LENGTH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_TAG_LENGTH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the AEAD algorithm that the operation performs.</li>
</ul>
<p>When this function returns, the operation becomes inactive.</p>
</div>
<div class="section" id="psa_aead_verify">
<span id="c.psa_aead_verify"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_verify</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_verify</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                             <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">plaintext</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="n">plaintext_size</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="o">*</span> <span class="n">plaintext_length</span><span class="p">,</span>
                             <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">tag</span><span class="p">,</span>
                             <span class="kt">size_t</span> <span class="n">tag_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Active AEAD operation.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">plaintext</span></code></dt>
<dd>Buffer where the last part of the plaintext is to be written. This is the remaining data from previous calls to <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> that could not be processed until the end of the input.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">plaintext_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">plaintext</span></code> buffer in bytes. This must be at least <a class="reference internal" href="#c.PSA_AEAD_VERIFY_OUTPUT_SIZE" title="PSA_AEAD_VERIFY_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_VERIFY_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the algorithm that is being calculated.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">plaintext_length</span></code></dt>
<dd>On success, the number of bytes of returned plaintext.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">tag</span></code></dt>
<dd>Buffer containing the authentication tag.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">tag_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">tag</span></code> buffer in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation state is not valid (not set up, nonce not set, encryption, or already completed).</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of the <code class="docutils literal notranslate"><span class="pre">plaintext</span></code> buffer is too small. You can determine a sufficient buffer size for <code class="docutils literal notranslate"><span class="pre">plaintext</span></code> by calling <a class="reference internal" href="#c.PSA_AEAD_VERIFY_OUTPUT_SIZE" title="PSA_AEAD_VERIFY_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_AEAD_VERIFY_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the algorithm that is being calculated.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The total length of input to <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> so far is less than the additional data length that was previously specified with <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The total length of input to <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> so far is less than the plaintext length that was previously specified with <a class="reference internal" href="#c.psa_aead_set_lengths" title="psa_aead_set_lengths"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_set_lengths()</span></code></a>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Finish authenticating and decrypting a message in an AEAD operation.</p>
<p>The operation must have been set up with <a class="reference internal" href="#c.psa_aead_decrypt_setup" title="psa_aead_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup()</span></code></a>.</p>
<p>This function finishes the authentication of the additional data formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_aead_update_ad" title="psa_aead_update_ad"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update_ad()</span></code></a> with the ciphertext formed by concatenating the inputs passed to preceding calls to <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>.</p>
<p>When this function returns, the operation becomes inactive.</p>
</div>
<div class="section" id="psa_aead_abort">
<span id="c.psa_aead_abort"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_aead_abort</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_aead_abort</span><span class="p">(</span><span class="n">psa_aead_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>Initialized AEAD operation.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">operation</span></code> is not an active AEAD operation.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Abort an AEAD operation.</p>
<p>Aborting an operation frees all associated resources except for the <code class="docutils literal notranslate"><span class="pre">operation</span></code> structure itself. Once aborted, the operation object can be reused for another operation by calling <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_aead_decrypt_setup" title="psa_aead_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup()</span></code></a> again.</p>
<p>You may call this function any time after the operation object has been initialized by any of the following methods:</p>
<ul class="simple">
<li>A call to <a class="reference internal" href="#c.psa_aead_encrypt_setup" title="psa_aead_encrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup()</span></code></a> or <a class="reference internal" href="#c.psa_aead_decrypt_setup" title="psa_aead_decrypt_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup()</span></code></a>, whether it succeeds or not.</li>
<li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to all-bits-zero.</li>
<li>Initializing the <code class="docutils literal notranslate"><span class="pre">struct</span></code> to logical zeros, e.g. <code class="docutils literal notranslate"><span class="pre">psa_aead_operation_t</span> <span class="pre">operation</span> <span class="pre">=</span> <span class="pre">{0}</span></code>.</li>
</ul>
<p>In particular, calling <a class="reference internal" href="#c.psa_aead_abort" title="psa_aead_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_abort()</span></code></a> after the operation has been terminated by a call to <a class="reference internal" href="#c.psa_aead_abort" title="psa_aead_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_abort()</span></code></a> or <a class="reference internal" href="#c.psa_aead_finish" title="psa_aead_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_finish()</span></code></a> is safe and has no effect.</p>
</div>
</div>
<div class="section" id="asymmetric-cryptography">
<h1>Asymmetric cryptography</h1>
<div class="section" id="psa_asymmetric_sign">
<span id="c.psa_asymmetric_sign"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_sign</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_asymmetric_sign</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                                 <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span>
                                 <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">hash</span><span class="p">,</span>
                                 <span class="kt">size_t</span> <span class="n">hash_length</span><span class="p">,</span>
                                 <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">signature</span><span class="p">,</span>
                                 <span class="kt">size_t</span> <span class="n">signature_size</span><span class="p">,</span>
                                 <span class="kt">size_t</span> <span class="o">*</span> <span class="n">signature_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation. It must be an asymmetric key pair.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>A signature algorithm that is compatible with the type of <code class="docutils literal notranslate"><span class="pre">handle</span></code>.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">hash</span></code></dt>
<dd>The hash or message to sign.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">hash_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">hash</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">signature</span></code></dt>
<dd>Buffer where the signature is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">signature_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">signature</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">signature_length</span></code></dt>
<dd>On success, the number of bytes that make up the returned signature value.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of the <code class="docutils literal notranslate"><span class="pre">signature</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE" title="PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">key_type</span></code>, <code class="docutils literal notranslate"><span class="pre">key_bits</span></code>, <code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">key_type</span></code> and <code class="docutils literal notranslate"><span class="pre">key_bits</span></code> are the type and bit-size respectively of <code class="docutils literal notranslate"><span class="pre">handle</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Sign a hash or short message with a private key.</p>
<p>Note that to perform a hash-and-sign signature algorithm, you must first calculate the hash by calling <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a>, <a class="reference internal" href="#c.psa_hash_update" title="psa_hash_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_update()</span></code></a> and <a class="reference internal" href="#c.psa_hash_finish" title="psa_hash_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_finish()</span></code></a>. Then pass the resulting hash as the <code class="docutils literal notranslate"><span class="pre">hash</span></code> parameter to this function. You can use <a class="reference internal" href="#c.PSA_ALG_SIGN_GET_HASH" title="PSA_ALG_SIGN_GET_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_SIGN_GET_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) to determine the hash algorithm to use.</p>
</div>
<div class="section" id="psa_asymmetric_verify">
<span id="c.psa_asymmetric_verify"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_verify</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_asymmetric_verify</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                                   <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span>
                                   <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">hash</span><span class="p">,</span>
                                   <span class="kt">size_t</span> <span class="n">hash_length</span><span class="p">,</span>
                                   <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">signature</span><span class="p">,</span>
                                   <span class="kt">size_t</span> <span class="n">signature_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation. It must be a public key or an asymmetric key pair.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>A signature algorithm that is compatible with the type of <code class="docutils literal notranslate"><span class="pre">handle</span></code>.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">hash</span></code></dt>
<dd>The hash or message whose signature is to be verified.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">hash_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">hash</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">signature</span></code></dt>
<dd>Buffer containing the signature to verify.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">signature_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">signature</span></code> buffer in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The signature is valid.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_SIGNATURE" title="PSA_ERROR_INVALID_SIGNATURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The calculation was perfomed successfully, but the passed signature is not a valid signature.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Verify the signature a hash or short message using a public key.</p>
<p>Note that to perform a hash-and-sign signature algorithm, you must first calculate the hash by calling <a class="reference internal" href="#c.psa_hash_setup" title="psa_hash_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_setup()</span></code></a>, <a class="reference internal" href="#c.psa_hash_update" title="psa_hash_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_update()</span></code></a> and <a class="reference internal" href="#c.psa_hash_finish" title="psa_hash_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_finish()</span></code></a>. Then pass the resulting hash as the <code class="docutils literal notranslate"><span class="pre">hash</span></code> parameter to this function. You can use <a class="reference internal" href="#c.PSA_ALG_SIGN_GET_HASH" title="PSA_ALG_SIGN_GET_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_SIGN_GET_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) to determine the hash algorithm to use.</p>
</div>
<div class="section" id="psa_asymmetric_encrypt">
<span id="c.psa_asymmetric_encrypt"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_encrypt</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_asymmetric_encrypt</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                                    <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span>
                                    <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span>
                                    <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span>
                                    <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">salt</span><span class="p">,</span>
                                    <span class="kt">size_t</span> <span class="n">salt_length</span><span class="p">,</span>
                                    <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span>
                                    <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span>
                                    <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation. It must be a public key or an asymmetric key pair.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An asymmetric encryption algorithm that is compatible with the type of <code class="docutils literal notranslate"><span class="pre">handle</span></code>.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt>
<dd>The message to encrypt.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">salt</span></code></dt>
<dd>A salt or label, if supported by the encryption algorithm. If the algorithm does not support a salt, pass <code class="docutils literal notranslate"><span class="pre">NULL</span></code>. If the algorithm supports an optional salt and you do not want to pass a salt, pass <code class="docutils literal notranslate"><span class="pre">NULL</span></code>.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">salt_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">salt</span></code> buffer in bytes. If <code class="docutils literal notranslate"><span class="pre">salt</span></code> is <code class="docutils literal notranslate"><span class="pre">NULL</span></code>, pass 0.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt>
<dd>Buffer where the encrypted message is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt>
<dd>On success, the number of bytes that make up the returned output.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE" title="PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">key_type</span></code>, <code class="docutils literal notranslate"><span class="pre">key_bits</span></code>, <code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">key_type</span></code> and <code class="docutils literal notranslate"><span class="pre">key_bits</span></code> are the type and bit-size respectively of <code class="docutils literal notranslate"><span class="pre">handle</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Encrypt a short message with a public key.</p>
<ul class="simple">
<li>For <a class="reference internal" href="#c.PSA_ALG_RSA_PKCS1V15_CRYPT" title="PSA_ALG_RSA_PKCS1V15_CRYPT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_CRYPT</span></code></a>, no salt is supported.</li>
</ul>
</div>
<div class="section" id="psa_asymmetric_decrypt">
<span id="c.psa_asymmetric_decrypt"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_decrypt</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_asymmetric_decrypt</span><span class="p">(</span><span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">,</span>
                                    <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span>
                                    <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">input</span><span class="p">,</span>
                                    <span class="kt">size_t</span> <span class="n">input_length</span><span class="p">,</span>
                                    <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">salt</span><span class="p">,</span>
                                    <span class="kt">size_t</span> <span class="n">salt_length</span><span class="p">,</span>
                                    <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span>
                                    <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span>
                                    <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key to use for the operation. It must be an asymmetric key pair.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An asymmetric encryption algorithm that is compatible with the type of <code class="docutils literal notranslate"><span class="pre">handle</span></code>.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input</span></code></dt>
<dd>The message to decrypt.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">input</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">salt</span></code></dt>
<dd>A salt or label, if supported by the encryption algorithm. If the algorithm does not support a salt, pass <code class="docutils literal notranslate"><span class="pre">NULL</span></code>. If the algorithm supports an optional salt and you do not want to pass a salt, pass <code class="docutils literal notranslate"><span class="pre">NULL</span></code>.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">salt_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">salt</span></code> buffer in bytes. If <code class="docutils literal notranslate"><span class="pre">salt</span></code> is <code class="docutils literal notranslate"><span class="pre">NULL</span></code>, pass 0.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt>
<dd>Buffer where the decrypted message is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt>
<dd>On success, the number of bytes that make up the returned output.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer is too small. You can determine a sufficient buffer size by calling <a class="reference internal" href="#c.PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE" title="PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">key_type</span></code>, <code class="docutils literal notranslate"><span class="pre">key_bits</span></code>, <code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">key_type</span></code> and <code class="docutils literal notranslate"><span class="pre">key_bits</span></code> are the type and bit-size respectively of <code class="docutils literal notranslate"><span class="pre">handle</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_PADDING" title="PSA_ERROR_INVALID_PADDING"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_PADDING</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Decrypt a short message with a private key.</p>
<ul class="simple">
<li>For <a class="reference internal" href="#c.PSA_ALG_RSA_PKCS1V15_CRYPT" title="PSA_ALG_RSA_PKCS1V15_CRYPT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_CRYPT</span></code></a>, no salt is supported.</li>
</ul>
</div>
</div>
<div class="section" id="key-derivation-and-pseudorandom-generation">
<h1>Key derivation and pseudorandom generation</h1>
<div class="section" id="psa_key_derivation_operation_t">
<span id="c.psa_key_derivation_operation_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_operation_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="k">struct</span> <span class="n">psa_key_derivation_s</span> <span class="n">psa_key_derivation_operation_t</span><span class="p">;</span>
</pre></div>
</div>
<p>The type of the state data structure for key derivation operations.</p>
<p>Before calling any function on a key derivation operation object, the application must initialize it by any of the following means:</p>
<ul>
<li><p class="first">Set the structure to all-bits-zero, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_derivation_operation_t</span> <span class="n">operation</span><span class="p">;</span>
<span class="n">memset</span><span class="p">(</span><span class="o">&amp;</span><span class="n">operation</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="k">sizeof</span><span class="p">(</span><span class="n">operation</span><span class="p">));</span>
</pre></div>
</div>
</li>
<li><p class="first">Initialize the structure to logical zero values, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_derivation_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="p">{</span><span class="mi">0</span><span class="p">};</span>
</pre></div>
</div>
</li>
<li><p class="first">Initialize the structure to the initializer <a class="reference internal" href="#c.PSA_KEY_DERIVATION_OPERATION_INIT" title="PSA_KEY_DERIVATION_OPERATION_INIT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_OPERATION_INIT</span></code></a>, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_derivation_operation_t</span> <span class="n">operation</span> <span class="o">=</span> <span class="n">PSA_KEY_DERIVATION_OPERATION_INIT</span><span class="p">;</span>
</pre></div>
</div>
</li>
<li><p class="first">Assign the result of the function <a class="reference internal" href="#c.psa_key_derivation_operation_init" title="psa_key_derivation_operation_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_operation_init()</span></code></a> to the structure, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_derivation_operation_t</span> <span class="n">operation</span><span class="p">;</span>
<span class="n">operation</span> <span class="o">=</span> <span class="n">psa_key_derivation_operation_init</span><span class="p">();</span>
</pre></div>
</div>
</li>
</ul>
<p>This is an implementation-defined <code class="docutils literal notranslate"><span class="pre">struct</span></code>. Applications should not make any assumptions about the content of this structure except as directed by the documentation of a specific implementation.</p>
</div>
<div class="section" id="PSA_KEY_DERIVATION_OPERATION_INIT">
<span id="c.PSA_KEY_DERIVATION_OPERATION_INIT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_OPERATION_INIT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_DERIVATION_OPERATION_INIT  {0}</span>
</pre></div>
</div>
<p>This macro returns a suitable initializer for a key derivation operation object of type <a class="reference internal" href="#c.psa_key_derivation_operation_t" title="psa_key_derivation_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_derivation_operation_t</span></code></a>.</p>
</div>
<div class="section" id="PSA_KEY_DERIVATION_UNLIMITED_CAPACITY">
<span id="c.PSA_KEY_DERIVATION_UNLIMITED_CAPACITY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_UNLIMITED_CAPACITY</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_DERIVATION_UNLIMITED_CAPACITY  ((size_t)(-1))</span>
</pre></div>
</div>
<p>Use the maximum possible capacity for a key derivation operation.</p>
<p>Use this value as the capacity argument when setting up a key derivation to indicate that the operation should have the maximum possible capacity. The value of the maximum possible capacity depends on the key derivation algorithm.</p>
</div>
<div class="section" id="psa_key_derivation_operation_init">
<span id="c.psa_key_derivation_operation_init"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_operation_init</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_derivation_operation_t</span> <span class="nf">psa_key_derivation_operation_init</span><span class="p">(</span><span class="kt">void</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_key_derivation_operation_t" title="psa_key_derivation_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_operation_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Return an initial value for a key derivation operation object.</p>
</div>
<div class="section" id="psa_key_derivation_setup">
<span id="c.psa_key_derivation_setup"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_setup</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_setup</span><span class="p">(</span><span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                      <span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The key derivation operation object to set up. It must have been initialized but not set up yet.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The key derivation algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_KEY_DERIVATION" title="PSA_ALG_IS_KEY_DERIVATION"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_DERIVATION</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a key derivation algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a key derivation algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Set up a key derivation operation.</p>
<p>A key derivation algorithm takes some inputs and uses them to generate a byte stream in a deterministic way. This byte stream can be used to produce keys and other cryptographic material.</p>
<p>To derive a key:</p>
<ul class="simple">
<li>Start with an initialized object of type <a class="reference internal" href="#c.psa_key_derivation_operation_t" title="psa_key_derivation_operation_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_derivation_operation_t</span></code></a>.</li>
<li>Call <a class="reference internal" href="#c.psa_key_derivation_setup" title="psa_key_derivation_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_setup()</span></code></a> to select the algorithm.</li>
<li>Provide the inputs for the key derivation by calling <a class="reference internal" href="#c.psa_key_derivation_input_bytes" title="psa_key_derivation_input_bytes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_input_bytes()</span></code></a> or <a class="reference internal" href="#c.psa_key_derivation_input_key" title="psa_key_derivation_input_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_input_key()</span></code></a> as appropriate. Which inputs are needed, in what order, and whether they may be keys and if so of what type depends on the algorithm.</li>
<li>Optionally set the operation’s maximum capacity with <a class="reference internal" href="#c.psa_key_derivation_set_capacity" title="psa_key_derivation_set_capacity"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_set_capacity()</span></code></a>. You may do this before, in the middle of or after providing inputs. For some algorithms, this step is mandatory because the output depends on the maximum capacity.</li>
<li>To derive a key, call <a class="reference internal" href="#c.psa_key_derivation_output_key" title="psa_key_derivation_output_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_output_key()</span></code></a>. To derive a byte string for a different purpose, call</li>
<li><a class="reference internal" href="#c.psa_key_derivation_output_bytes" title="psa_key_derivation_output_bytes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_output_bytes()</span></code></a>. Successive calls to these functions use successive output bytes calculated by the key derivation algorithm.</li>
<li>Clean up the key derivation operation object with <a class="reference internal" href="#c.psa_key_derivation_abort" title="psa_key_derivation_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_abort()</span></code></a>.</li>
</ul>
</div>
<div class="section" id="psa_key_derivation_get_capacity">
<span id="c.psa_key_derivation_get_capacity"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_get_capacity</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_get_capacity</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                             <span class="kt">size_t</span> <span class="o">*</span> <span class="n">capacity</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The operation to query.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">capacity</span></code></dt>
<dd>On success, the capacity of the operation.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Retrieve the current capacity of a key derivation operation.</p>
<p>The capacity of a key derivation is the maximum number of bytes that it can return. When you get <em>N</em> bytes of output from a key derivation operation, this reduces its capacity by <em>N</em>.</p>
</div>
<div class="section" id="psa_key_derivation_set_capacity">
<span id="c.psa_key_derivation_set_capacity"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_set_capacity</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_set_capacity</span><span class="p">(</span><span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                             <span class="kt">size_t</span> <span class="n">capacity</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The key derivation operation object to modify.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">capacity</span></code></dt>
<dd>The new capacity of the operation. It must be less or equal to the operation’s current capacity.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">capacity</span></code> is larger than the operation’s current capacity. In this case, the operation object remains valid and its capacity remains unchanged.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Set the maximum capacity of a key derivation operation.</p>
<p>The capacity of a key derivation operation is the maximum number of bytes that the key derivation operation can return from this point onwards.</p>
</div>
<div class="section" id="psa_key_derivation_input_bytes">
<span id="c.psa_key_derivation_input_bytes"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_input_bytes</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_input_bytes</span><span class="p">(</span><span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                            <span class="n">psa_key_derivation_step_t</span> <span class="n">step</span><span class="p">,</span>
                                            <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">data</span><span class="p">,</span>
                                            <span class="kt">size_t</span> <span class="n">data_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The key derivation operation object to use. It must have been set up with <a class="reference internal" href="#c.psa_key_derivation_setup" title="psa_key_derivation_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_setup()</span></code></a> and must not have produced any output yet.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">step</span></code></dt>
<dd>Which step the input data is for.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">data</span></code></dt>
<dd>Input data to use.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">data_length</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">data</span></code> buffer in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">step</span></code> is not compatible with the operation’s algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">step</span></code> does not allow direct inputs.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The value of <code class="docutils literal notranslate"><span class="pre">step</span></code> is not valid given the state of <code class="docutils literal notranslate"><span class="pre">operation</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Provide an input for key derivation or key agreement.</p>
<p>Which inputs are required and in what order depends on the algorithm. Refer to the documentation of each key derivation or key agreement algorithm for information.</p>
<p>This function passes direct inputs. Some inputs must be passed as keys using <a class="reference internal" href="#c.psa_key_derivation_input_key" title="psa_key_derivation_input_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_input_key()</span></code></a> instead of this function. Refer to the documentation of individual step types for information.</p>
</div>
<div class="section" id="psa_key_derivation_input_key">
<span id="c.psa_key_derivation_input_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_input_key</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_input_key</span><span class="p">(</span><span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                          <span class="n">psa_key_derivation_step_t</span> <span class="n">step</span><span class="p">,</span>
                                          <span class="n">psa_key_handle_t</span> <span class="n">handle</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The key derivation operation object to use. It must have been set up with <a class="reference internal" href="#c.psa_key_derivation_setup" title="psa_key_derivation_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_setup()</span></code></a> and must not have produced any output yet.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">step</span></code></dt>
<dd>Which step the input data is for.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>Handle to the key. It must have an appropriate type for <code class="docutils literal notranslate"><span class="pre">step</span></code> and must allow the usage <a class="reference internal" href="#c.PSA_KEY_USAGE_DERIVE" title="PSA_KEY_USAGE_DERIVE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_DERIVE</span></code></a>.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">step</span></code> is not compatible with the operation’s algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">step</span></code> does not allow key inputs.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The value of <code class="docutils literal notranslate"><span class="pre">step</span></code> is not valid given the state of <code class="docutils literal notranslate"><span class="pre">operation</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Provide an input for key derivation in the form of a key.</p>
<p>Which inputs are required and in what order depends on the algorithm. Refer to the documentation of each key derivation or key agreement algorithm for information.</p>
<p>This function passes key inputs. Some inputs must be passed as keys of the appropriate type using this function, while others must be passed as direct inputs using <a class="reference internal" href="#c.psa_key_derivation_input_bytes" title="psa_key_derivation_input_bytes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_input_bytes()</span></code></a>. Refer to the documentation of individual step types for information.</p>
</div>
<div class="section" id="psa_key_derivation_key_agreement">
<span id="c.psa_key_derivation_key_agreement"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_key_agreement</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_key_agreement</span><span class="p">(</span><span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                              <span class="n">psa_key_derivation_step_t</span> <span class="n">step</span><span class="p">,</span>
                                              <span class="n">psa_key_handle_t</span> <span class="n">private_key</span><span class="p">,</span>
                                              <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">peer_key</span><span class="p">,</span>
                                              <span class="kt">size_t</span> <span class="n">peer_key_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The key derivation operation object to use. It must have been set up with <a class="reference internal" href="#c.psa_key_derivation_setup" title="psa_key_derivation_setup"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_setup()</span></code></a> with a key agreement and derivation algorithm <code class="docutils literal notranslate"><span class="pre">alg</span></code> (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_KEY_AGREEMENT" title="PSA_ALG_IS_KEY_AGREEMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_AGREEMENT</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true and <a class="reference internal" href="#c.PSA_ALG_IS_RAW_KEY_AGREEMENT" title="PSA_ALG_IS_RAW_KEY_AGREEMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_RAW_KEY_AGREEMENT</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is false). The operation must be ready for an input of the type given by <code class="docutils literal notranslate"><span class="pre">step</span></code>.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">step</span></code></dt>
<dd>Which step the input data is for.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">private_key</span></code></dt>
<dd>Handle to the private key to use.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">peer_key</span></code></dt>
<dd>Public key of the peer. The peer key must be in the same format that <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a> accepts for the public key type corresponding to the type of private_key. That is, this function performs the equivalent of <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key</span></code></a>(…, <code class="docutils literal notranslate"><span class="pre">peer_key</span></code>, <code class="docutils literal notranslate"><span class="pre">peer_key_length</span></code>) where with key attributes indicating the public key type corresponding to the type of <code class="docutils literal notranslate"><span class="pre">private_key</span></code>. For example, for EC keys, this means that peer_key is interpreted as a point on the curve that the private key is on. The standard formats for public keys are documented in the documentation of <a class="reference internal" href="#c.psa_export_public_key" title="psa_export_public_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_public_key()</span></code></a>.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">peer_key_length</span></code></dt>
<dd>Size of <code class="docutils literal notranslate"><span class="pre">peer_key</span></code> in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">private_key</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>, or <code class="docutils literal notranslate"><span class="pre">peer_key</span></code> is not valid for <code class="docutils literal notranslate"><span class="pre">alg</span></code> or not compatible with <code class="docutils literal notranslate"><span class="pre">private_key</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not supported or is not a key derivation algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Perform a key agreement and use the shared secret as input to a key derivation.</p>
<p>A key agreement algorithm takes two inputs: a private key <code class="docutils literal notranslate"><span class="pre">private_key</span></code> a public key <code class="docutils literal notranslate"><span class="pre">peer_key</span></code>. The result of this function is passed as input to a key derivation. The output of this key derivation can be extracted by reading from the resulting operation to produce keys and other cryptographic material.</p>
</div>
<div class="section" id="psa_key_derivation_output_bytes">
<span id="c.psa_key_derivation_output_bytes"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_output_bytes</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_output_bytes</span><span class="p">(</span><span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                             <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span>
                                             <span class="kt">size_t</span> <span class="n">output_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The key derivation operation object to read from.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt>
<dd>Buffer where the output will be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt>
<dd>Number of bytes to output.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_DATA" title="PSA_ERROR_INSUFFICIENT_DATA"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_DATA</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The operation’s capacity was less than <code class="docutils literal notranslate"><span class="pre">output_length</span></code> bytes. Note that in this case, no output is written to the output buffer. The operation’s capacity is set to 0, thus subsequent calls to this function will not succeed, even with a smaller output buffer.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Read some data from a key derivation operation.</p>
<p>This function calculates output bytes from a key derivation algorithm and return those bytes. If you view the key derivation’s output as a stream of bytes, this function destructively reads the requested number of bytes from the stream. The operation’s capacity decreases by the number of bytes read.</p>
</div>
<div class="section" id="psa_key_derivation_output_key">
<span id="c.psa_key_derivation_output_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_output_key</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_output_key</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span>
                                           <span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">,</span>
                                           <span class="n">psa_key_handle_t</span> <span class="o">*</span> <span class="n">handle</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The attributes for the new key.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The key derivation operation object to read from.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>On success, a handle to the newly created key. <code class="docutils literal notranslate"><span class="pre">0</span></code> on failure.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success. If the key is persistent, the key material and the key’s metadata have been saved to persistent storage.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_ALREADY_EXISTS" title="PSA_ERROR_ALREADY_EXISTS"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_ALREADY_EXISTS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>This is an attempt to create a persistent key, and there is already a persistent key with the given identifier.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_DATA" title="PSA_ERROR_INSUFFICIENT_DATA"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_DATA</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>There was not enough data to create the desired key. Note that in this case, no output is written to the output buffer. The operation’s capacity is set to 0, thus subsequent calls to this function will not succeed, even with a smaller output buffer.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The key type or key size is not supported, either by the implementation in general or in this particular location.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_STORAGE" title="PSA_ERROR_INSUFFICIENT_STORAGE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_STORAGE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Derive a key from an ongoing key derivation operation.</p>
<p>This function calculates output bytes from a key derivation algorithm and uses those bytes to generate a key deterministically. If you view the key derivation’s output as a stream of bytes, this function destructively reads as many bytes as required from the stream. The operation’s capacity decreases by the number of bytes read.</p>
<p>How much output is produced and consumed from the operation, and how the key is derived, depends on the key type:</p>
<ul class="simple">
<li>For key types for which the key is an arbitrary sequence of bytes of a given size, this function is functionally equivalent to calling <a class="reference internal" href="#c.psa_key_derivation_output_bytes" title="psa_key_derivation_output_bytes"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_output_bytes</span></code></a> and passing the resulting output to <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key</span></code></a>. However, this function has a security benefit: if the implementation provides an isolation boundary then the key material is not exposed outside the isolation boundary. As a consequence, for these key types, this function always consumes exactly (<code class="docutils literal notranslate"><span class="pre">bits</span></code> / 8) bytes from the operation. The following key types defined in this specification follow this scheme:<ul>
<li><a class="reference internal" href="#c.PSA_KEY_TYPE_AES" title="PSA_KEY_TYPE_AES"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_AES</span></code></a>;</li>
<li><a class="reference internal" href="#c.PSA_KEY_TYPE_ARC4" title="PSA_KEY_TYPE_ARC4"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ARC4</span></code></a>;</li>
<li><a class="reference internal" href="#c.PSA_KEY_TYPE_CAMELLIA" title="PSA_KEY_TYPE_CAMELLIA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CAMELLIA</span></code></a>;</li>
<li><a class="reference internal" href="#c.PSA_KEY_TYPE_DERIVE" title="PSA_KEY_TYPE_DERIVE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DERIVE</span></code></a>;</li>
<li><a class="reference internal" href="#c.PSA_KEY_TYPE_HMAC" title="PSA_KEY_TYPE_HMAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_HMAC</span></code></a>.</li>
</ul>
</li>
<li>For ECC keys on a Montgomery elliptic curve (<a class="reference internal" href="#c.PSA_KEY_TYPE_ECC_KEY_PAIR" title="PSA_KEY_TYPE_ECC_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR</span></code></a>(<code class="docutils literal notranslate"><span class="pre">curve</span></code>) where <code class="docutils literal notranslate"><span class="pre">curve</span></code> designates a Montgomery curve), this function always draws a byte string whose length is determined by the curve, and sets the mandatory bits accordingly. That is:<ul>
<li><a class="reference internal" href="#c.PSA_ECC_CURVE_CURVE25519" title="PSA_ECC_CURVE_CURVE25519"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVE25519</span></code></a>: draw a 32-byte string and process it as specified in RFC 7748 §5.</li>
<li><a class="reference internal" href="#c.PSA_ECC_CURVE_CURVE448" title="PSA_ECC_CURVE_CURVE448"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVE448</span></code></a>: draw a 56-byte string and process it as specified in RFC 7748 §5.</li>
</ul>
</li>
<li>For key types for which the key is represented by a single sequence of <code class="docutils literal notranslate"><span class="pre">bits</span></code> bits with constraints as to which bit sequences are acceptable, this function draws a byte string of length (<code class="docutils literal notranslate"><span class="pre">bits</span></code> / 8) bytes rounded up to the nearest whole number of bytes. If the resulting byte string is acceptable, it becomes the key, otherwise the drawn bytes are discarded. This process is repeated until an acceptable byte string is drawn. The byte string drawn from the operation is interpreted as specified for the output produced by <a class="reference internal" href="#c.psa_export_key" title="psa_export_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_key()</span></code></a>. The following key types defined in this specification follow this scheme:<ul>
<li><a class="reference internal" href="#c.PSA_KEY_TYPE_DES" title="PSA_KEY_TYPE_DES"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DES</span></code></a>. Force-set the parity bits, but discard forbidden weak keys. For 2-key and 3-key triple-DES, the three keys are generated successively (for example, for 3-key triple-DES, if the first 8 bytes specify a weak key and the next 8 bytes do not, discard the first 8 bytes, use the next 8 bytes as the first key, and continue reading output from the operation to derive the other two keys).</li>
<li>Finite-field Diffie-Hellman keys (<a class="reference internal" href="#c.PSA_KEY_TYPE_DH_KEY_PAIR" title="PSA_KEY_TYPE_DH_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_KEY_PAIR</span></code></a>(<code class="docutils literal notranslate"><span class="pre">group</span></code>) where <code class="docutils literal notranslate"><span class="pre">group</span></code> designates any Diffie-Hellman group) and ECC keys on a Weierstrass elliptic curve (<a class="reference internal" href="#c.PSA_KEY_TYPE_ECC_KEY_PAIR" title="PSA_KEY_TYPE_ECC_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR</span></code></a>(<code class="docutils literal notranslate"><span class="pre">curve</span></code>) where <code class="docutils literal notranslate"><span class="pre">curve</span></code> designates a Weierstrass curve). For these key types, interpret the byte string as integer in big-endian order. Discard it if it is not in the range [0, <em>N</em> - 2] where <em>N</em> is the boundary of the private key domain (the prime <em>p</em> for Diffie-Hellman, the subprime <em>q</em> for DSA, or the order of the curve’s base point for ECC). Add 1 to the resulting integer and use this as the private key <em>x</em>. This method allows compliance to NIST standards, specifically the methods titled “key-pair generation by testing candidates” in NIST SP 800-56A §5.6.1.1.4 for Diffie-Hellman, in FIPS 186-4 §B.1.2 for DSA, and in NIST SP 800-56A §5.6.1.2.2 or FIPS 186-4 §B.4.2 for elliptic curve keys.</li>
</ul>
</li>
<li>For other key types, including <a class="reference internal" href="#c.PSA_KEY_TYPE_RSA_KEY_PAIR" title="PSA_KEY_TYPE_RSA_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_KEY_PAIR</span></code></a>, the way in which the operation output is consumed is implementation-defined.</li>
</ul>
<p>In all cases, the data that is read is discarded from the operation. The operation’s capacity is decreased by the number of bytes read.</p>
</div>
<div class="section" id="psa_key_derivation_abort">
<span id="c.psa_key_derivation_abort"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_abort</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_key_derivation_abort</span><span class="p">(</span><span class="n">psa_key_derivation_operation_t</span> <span class="o">*</span> <span class="n">operation</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">operation</span></code></dt>
<dd>The operation to abort.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Abort a key derivation operation.</p>
<p>Once a key derivation operation has been aborted, its capacity is zero. Aborting an operation frees all associated resources except for the <code class="docutils literal notranslate"><span class="pre">operation</span></code> structure itself.</p>
<p>This function may be called at any time as long as the operation object has been initialized to <a class="reference internal" href="#c.PSA_KEY_DERIVATION_OPERATION_INIT" title="PSA_KEY_DERIVATION_OPERATION_INIT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_OPERATION_INIT</span></code></a>, to <a class="reference internal" href="#c.psa_key_derivation_operation_init" title="psa_key_derivation_operation_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_operation_init()</span></code></a> or a zero value. In particular, it is valid to call <a class="reference internal" href="#c.psa_key_derivation_abort" title="psa_key_derivation_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_abort()</span></code></a> twice, or to call <a class="reference internal" href="#c.psa_key_derivation_abort" title="psa_key_derivation_abort"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_abort()</span></code></a> on an operation that has not been set up.</p>
<p>Once aborted, the key derivation operation object may be called.</p>
</div>
<div class="section" id="psa_raw_key_agreement">
<span id="c.psa_raw_key_agreement"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_raw_key_agreement</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_raw_key_agreement</span><span class="p">(</span><span class="n">psa_algorithm_t</span> <span class="n">alg</span><span class="p">,</span>
                                   <span class="n">psa_key_handle_t</span> <span class="n">private_key</span><span class="p">,</span>
                                   <span class="k">const</span> <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">peer_key</span><span class="p">,</span>
                                   <span class="kt">size_t</span> <span class="n">peer_key_length</span><span class="p">,</span>
                                   <span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span>
                                   <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">,</span>
                                   <span class="kt">size_t</span> <span class="o">*</span> <span class="n">output_length</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The key agreement algorithm to compute (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_RAW_KEY_AGREEMENT" title="PSA_ALG_IS_RAW_KEY_AGREEMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_RAW_KEY_AGREEMENT</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">private_key</span></code></dt>
<dd>Handle to the private key to use.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">peer_key</span></code></dt>
<dd>Public key of the peer. It must be in the same format that <a class="reference internal" href="#c.psa_import_key" title="psa_import_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_import_key()</span></code></a> accepts. The standard formats for public keys are documented in the documentation of <a class="reference internal" href="#c.psa_export_public_key" title="psa_export_public_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_public_key()</span></code></a>.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">peer_key_length</span></code></dt>
<dd>Size of <code class="docutils literal notranslate"><span class="pre">peer_key</span></code> in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt>
<dd>Buffer where the decrypted message is to be written.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt>
<dd>Size of the <code class="docutils literal notranslate"><span class="pre">output</span></code> buffer in bytes.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_length</span></code></dt>
<dd>On success, the number of bytes that make up the returned output.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a key agreement algorithm</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">private_key</span></code> is not compatible with <code class="docutils literal notranslate"><span class="pre">alg</span></code>, or <code class="docutils literal notranslate"><span class="pre">peer_key</span></code> is not valid for <code class="docutils literal notranslate"><span class="pre">alg</span></code> or not compatible with <code class="docutils literal notranslate"><span class="pre">private_key</span></code>.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd><code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported key agreement algorithm.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Perform a key agreement and return the raw shared secret.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">The raw result of a key agreement algorithm such as finite-field Diffie-Hellman or elliptic curve Diffie-Hellman has biases and should not be used directly as key material. It should instead be passed as input to a key derivation algorithm. To chain a key agreement with a key derivation, use <a class="reference internal" href="#c.psa_key_derivation_key_agreement" title="psa_key_derivation_key_agreement"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_key_derivation_key_agreement()</span></code></a> and other functions from the key derivation interface.</p>
</div>
</div>
</div>
<div class="section" id="random-generation">
<h1>Random generation</h1>
<div class="section" id="psa_generate_random">
<span id="c.psa_generate_random"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_generate_random</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_generate_random</span><span class="p">(</span><span class="kt">uint8_t</span> <span class="o">*</span> <span class="n">output</span><span class="p">,</span>
                                 <span class="kt">size_t</span> <span class="n">output_size</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">output</span></code></dt>
<dd>Output buffer for the generated data.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">output_size</span></code></dt>
<dd>Number of bytes to generate and output.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Generate random bytes.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">This function <strong>can</strong> fail! Callers MUST check the return status and MUST NOT use the content of the output buffer if the return status is not <a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a>.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">To generate a key, use <a class="reference internal" href="#c.psa_generate_key" title="psa_generate_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_generate_key()</span></code></a> instead.</p>
</div>
</div>
<div class="section" id="psa_generate_key">
<span id="c.psa_generate_key"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_generate_key</span></code> (function)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_status_t</span> <span class="nf">psa_generate_key</span><span class="p">(</span><span class="k">const</span> <span class="n">psa_key_attributes_t</span> <span class="o">*</span> <span class="n">attributes</span><span class="p">,</span>
                              <span class="n">psa_key_handle_t</span> <span class="o">*</span> <span class="n">handle</span><span class="p">);</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">attributes</span></code></dt>
<dd>The attributes for the new key.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">handle</span></code></dt>
<dd>On success, a handle to the newly created key. <code class="docutils literal notranslate"><span class="pre">0</span></code> on failure.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.psa_status_t" title="psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>Success. If the key is persistent, the key material and the key’s metadata have been saved to persistent storage.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_ALREADY_EXISTS" title="PSA_ERROR_ALREADY_EXISTS"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_ALREADY_EXISTS</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>This is an attempt to create a persistent key, and there is already a persistent key with the given identifier.</dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_MEMORY" title="PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"></code><a class="reference internal" href="#c.PSA_ERROR_BAD_STATE" title="PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code></a><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code><code class="docutils literal notranslate"></code></dt>
<dd>The library has not been previously initialized by <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a>. It is implementation-dependent whether a failure to initialize results in this error code.</dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Generate a key or key pair.</p>
<p>The key is generated randomly. Its location, policy, type and size are taken from <code class="docutils literal notranslate"><span class="pre">attributes</span></code>.</p>
<p>The following type-specific considerations apply:</p>
<ul class="simple">
<li>For RSA keys (<a class="reference internal" href="#c.PSA_KEY_TYPE_RSA_KEY_PAIR" title="PSA_KEY_TYPE_RSA_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_KEY_PAIR</span></code></a>), the public exponent is 65537. The modulus is a product of two probabilistic primes between 2^{n-1} and 2^n where n is the bit size specified in the attributes.</li>
</ul>
</div>
</div>
<div class="section" id="error-codes">
<h1>Error codes</h1>
<div class="section" id="psa_status_t">
<span id="c.psa_status_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">int32_t</span> <span class="n">psa_status_t</span><span class="p">;</span>
</pre></div>
</div>
<p>Function return status.</p>
<p>This is either <a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a> (which is zero), indicating success, or a small negative value indicating that an error occurred. Errors are encoded as one of the <code class="docutils literal notranslate"><span class="pre">PSA_ERROR_xxx</span></code> values defined here.</p>
</div>
<div class="section" id="PSA_SUCCESS">
<span id="c.PSA_SUCCESS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_SUCCESS  ((psa_status_t)0)</span>
</pre></div>
</div>
<p>The action was completed successfully.</p>
</div>
<div class="section" id="PSA_ERROR_GENERIC_ERROR">
<span id="c.PSA_ERROR_GENERIC_ERROR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_GENERIC_ERROR</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_GENERIC_ERROR  ((psa_status_t)-132)</span>
</pre></div>
</div>
<p>An error occurred that does not correspond to any defined failure cause.</p>
<p>Implementations may use this error code if none of the other standard error codes are applicable.</p>
</div>
<div class="section" id="PSA_ERROR_NOT_SUPPORTED">
<span id="c.PSA_ERROR_NOT_SUPPORTED"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_NOT_SUPPORTED  ((psa_status_t)-134)</span>
</pre></div>
</div>
<p>The requested operation or a parameter is not supported by this implementation.</p>
<p>Implementations should return this error code when an enumeration parameter such as a key type, algorithm, etc. is not recognized. If a combination of parameters is recognized and identified as not valid, return <a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a> instead.</p>
</div>
<div class="section" id="PSA_ERROR_NOT_PERMITTED">
<span id="c.PSA_ERROR_NOT_PERMITTED"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_NOT_PERMITTED  ((psa_status_t)-133)</span>
</pre></div>
</div>
<p>The requested action is denied by a policy.</p>
<p>Implementations should return this error code when the parameters are recognized as valid and supported, and a policy explicitly denies the requested operation.</p>
<p>If a subset of the parameters of a function call identify a forbidden operation, and another subset of the parameters are not valid or not supported, it is unspecified whether the function returns <a class="reference internal" href="#c.PSA_ERROR_NOT_PERMITTED" title="PSA_ERROR_NOT_PERMITTED"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code></a>, <a class="reference internal" href="#c.PSA_ERROR_NOT_SUPPORTED" title="PSA_ERROR_NOT_SUPPORTED"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code></a> or <a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a>.</p>
</div>
<div class="section" id="PSA_ERROR_BUFFER_TOO_SMALL">
<span id="c.PSA_ERROR_BUFFER_TOO_SMALL"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_BUFFER_TOO_SMALL  ((psa_status_t)-138)</span>
</pre></div>
</div>
<p>An output buffer is too small.</p>
<p>Applications can call the <code class="docutils literal notranslate"><span class="pre">PSA_xxx_SIZE</span></code> macro listed in the function description to determine a sufficient buffer size.</p>
<p>Implementations should preferably return this error code only in cases when performing the operation with a larger output buffer would succeed. However implementations may return this error if a function has invalid or unsupported parameters in addition to the parameters that determine the necessary output buffer size.</p>
</div>
<div class="section" id="PSA_ERROR_ALREADY_EXISTS">
<span id="c.PSA_ERROR_ALREADY_EXISTS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_ALREADY_EXISTS</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_ALREADY_EXISTS  ((psa_status_t)-139)</span>
</pre></div>
</div>
<p>Asking for an item that already exists.</p>
<p>Implementations should return this error, when attempting to write an item (like a key) that already exists.</p>
</div>
<div class="section" id="PSA_ERROR_DOES_NOT_EXIST">
<span id="c.PSA_ERROR_DOES_NOT_EXIST"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_DOES_NOT_EXIST  ((psa_status_t)-140)</span>
</pre></div>
</div>
<p>Asking for an item that doesn’t exist.</p>
<p>Implementations should return this error, if a requested item (like a key) does not exist.</p>
</div>
<div class="section" id="PSA_ERROR_BAD_STATE">
<span id="c.PSA_ERROR_BAD_STATE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_BAD_STATE  ((psa_status_t)-137)</span>
</pre></div>
</div>
<p>The requested action cannot be performed in the current state.</p>
<p>Multipart operations return this error when one of the functions is called out of sequence. Refer to the function descriptions for permitted sequencing of functions.</p>
<p>Implementations shall not return this error code to indicate that a key either exists or not, but shall instead return <a class="reference internal" href="#c.PSA_ERROR_ALREADY_EXISTS" title="PSA_ERROR_ALREADY_EXISTS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_ALREADY_EXISTS</span></code></a> or <a class="reference internal" href="#c.PSA_ERROR_DOES_NOT_EXIST" title="PSA_ERROR_DOES_NOT_EXIST"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code></a> as applicable.</p>
<p>Implementations shall not return this error code to indicate that a key handle is invalid, but shall return <a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a> instead.</p>
</div>
<div class="section" id="PSA_ERROR_INVALID_ARGUMENT">
<span id="c.PSA_ERROR_INVALID_ARGUMENT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INVALID_ARGUMENT  ((psa_status_t)-135)</span>
</pre></div>
</div>
<p>The parameters passed to the function are invalid.</p>
<p>Implementations may return this error any time a parameter or combination of parameters are recognized as invalid.</p>
<p>Implementations shall not return this error code to indicate that a key handle is invalid, but shall return <a class="reference internal" href="#c.PSA_ERROR_INVALID_HANDLE" title="PSA_ERROR_INVALID_HANDLE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code></a> instead.</p>
</div>
<div class="section" id="PSA_ERROR_INSUFFICIENT_MEMORY">
<span id="c.PSA_ERROR_INSUFFICIENT_MEMORY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INSUFFICIENT_MEMORY  ((psa_status_t)-141)</span>
</pre></div>
</div>
<p>There is not enough runtime memory.</p>
<p>If the action is carried out across multiple security realms, this error can refer to available memory in any of the security realms.</p>
</div>
<div class="section" id="PSA_ERROR_INSUFFICIENT_STORAGE">
<span id="c.PSA_ERROR_INSUFFICIENT_STORAGE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_STORAGE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INSUFFICIENT_STORAGE  ((psa_status_t)-142)</span>
</pre></div>
</div>
<p>There is not enough persistent storage.</p>
<p>Functions that modify the key storage return this error code if there is insufficient storage space on the host media. In addition, many functions that do not otherwise access storage may return this error code if the implementation requires a mandatory log entry for the requested action and the log storage space is full.</p>
</div>
<div class="section" id="PSA_ERROR_COMMUNICATION_FAILURE">
<span id="c.PSA_ERROR_COMMUNICATION_FAILURE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_COMMUNICATION_FAILURE  ((psa_status_t)-145)</span>
</pre></div>
</div>
<p>There was a communication failure inside the implementation.</p>
<p>This can indicate a communication failure between the application and an external cryptoprocessor or between the cryptoprocessor and an external volatile or persistent memory. A communication failure may be transient or permanent depending on the cause.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">If a function returns this error, it is undetermined whether the requested action has completed or not. Implementations should return <a class="reference internal" href="#c.PSA_SUCCESS" title="PSA_SUCCESS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code></a> on successful completion whenver possible, however functions may return <a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a> if the requested action was completed successfully in an external cryptoprocessor but there was a breakdown of communication before the cryptoprocessor could report the status to the application.</p>
</div>
</div>
<div class="section" id="PSA_ERROR_STORAGE_FAILURE">
<span id="c.PSA_ERROR_STORAGE_FAILURE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_STORAGE_FAILURE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_STORAGE_FAILURE  ((psa_status_t)-146)</span>
</pre></div>
</div>
<p>There was a storage failure that may have led to data loss.</p>
<p>This error indicates that some persistent storage is corrupted. It should not be used for a corruption of volatile memory (use <a class="reference internal" href="#c.PSA_ERROR_CORRUPTION_DETECTED" title="PSA_ERROR_CORRUPTION_DETECTED"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code></a>), for a communication error between the cryptoprocessor and its external storage (use <a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a>), or when the storage is in a valid state but is full (use <a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_STORAGE" title="PSA_ERROR_INSUFFICIENT_STORAGE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_STORAGE</span></code></a>).</p>
<p>Note that a storage failure does not indicate that any data that was previously read is invalid. However this previously read data may no longer be readable from storage.</p>
<p>When a storage failure occurs, it is no longer possible to ensure the global integrity of the keystore. Depending on the global integrity guarantees offered by the implementation, access to other data may or may not fail even if the data is still readable but its integrity cannot be guaranteed.</p>
<p>Implementations should only use this error code to report a permanent storage corruption. However application writers should keep in mind that transient errors while reading the storage may be reported using this error code.</p>
</div>
<div class="section" id="PSA_ERROR_HARDWARE_FAILURE">
<span id="c.PSA_ERROR_HARDWARE_FAILURE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_HARDWARE_FAILURE  ((psa_status_t)-147)</span>
</pre></div>
</div>
<p>A hardware failure was detected.</p>
<p>A hardware failure may be transient or permanent depending on the cause.</p>
</div>
<div class="section" id="PSA_ERROR_CORRUPTION_DETECTED">
<span id="c.PSA_ERROR_CORRUPTION_DETECTED"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_CORRUPTION_DETECTED  ((psa_status_t)-151)</span>
</pre></div>
</div>
<p>A tampering attempt was detected.</p>
<p>If an application receives this error code, there is no guarantee that previously accessed or computed data was correct and remains confidential. Applications should not perform any security function and should enter a safe failure state.</p>
<p>Implementations may return this error code if they detect an invalid state that cannot happen during normal operation and that indicates that the implementation’s security guarantees no longer hold. Depending on the implementation architecture and on its security and safety goals, the implementation may forcibly terminate the application.</p>
<p>This error code is intended as a last resort when a security breach is detected and it is unsure whether the keystore data is still protected. Implementations shall only return this error code to report an alarm from a tampering detector, to indicate that the confidentiality of stored data can no longer be guaranteed, or to indicate that the integrity of previously returned data is now considered compromised. Implementations shall not use this error code to indicate a hardware failure that merely makes it impossible to perform the requested operation (use <a class="reference internal" href="#c.PSA_ERROR_COMMUNICATION_FAILURE" title="PSA_ERROR_COMMUNICATION_FAILURE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code></a>, <a class="reference internal" href="#c.PSA_ERROR_STORAGE_FAILURE" title="PSA_ERROR_STORAGE_FAILURE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_STORAGE_FAILURE</span></code></a>, <a class="reference internal" href="#c.PSA_ERROR_HARDWARE_FAILURE" title="PSA_ERROR_HARDWARE_FAILURE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code></a>, <a class="reference internal" href="#c.PSA_ERROR_INSUFFICIENT_ENTROPY" title="PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code></a> or other applicable error code instead).</p>
<p>This error indicates an attack against the application. Implementations shall not return this error code as a consequence of the behavior of the application itself.</p>
</div>
<div class="section" id="PSA_ERROR_INSUFFICIENT_ENTROPY">
<span id="c.PSA_ERROR_INSUFFICIENT_ENTROPY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INSUFFICIENT_ENTROPY  ((psa_status_t)-148)</span>
</pre></div>
</div>
<p>There is not enough entropy to generate random data needed for the requested action.</p>
<p>This error indicates a failure of a hardware random generator. Application writers should note that this error can be returned not only by functions whose purpose is to generate random data, such as key, IV or nonce generation, but also by functions that execute an algorithm with a randomized result, as well as functions that use randomization of intermediate computations as a countermeasure to certain attacks.</p>
<p>Implementations should avoid returning this error after <a class="reference internal" href="#c.psa_crypto_init" title="psa_crypto_init"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_crypto_init()</span></code></a> has succeeded. Implementations should generate sufficient entropy during initialization and subsequently use a cryptographically secure pseudorandom generator (PRNG). However implementations may return this error at any time if a policy requires the PRNG to be reseeded during normal operation.</p>
</div>
<div class="section" id="PSA_ERROR_INVALID_SIGNATURE">
<span id="c.PSA_ERROR_INVALID_SIGNATURE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INVALID_SIGNATURE  ((psa_status_t)-149)</span>
</pre></div>
</div>
<p>The signature, MAC or hash is incorrect.</p>
<p>Verification functions return this error if the verification calculations completed successfully, and the value to be verified was determined to be incorrect.</p>
<p>If the value to verify has an invalid size, implementations may return either <a class="reference internal" href="#c.PSA_ERROR_INVALID_ARGUMENT" title="PSA_ERROR_INVALID_ARGUMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code></a> or <a class="reference internal" href="#c.PSA_ERROR_INVALID_SIGNATURE" title="PSA_ERROR_INVALID_SIGNATURE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code></a>.</p>
</div>
<div class="section" id="PSA_ERROR_INVALID_PADDING">
<span id="c.PSA_ERROR_INVALID_PADDING"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_PADDING</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INVALID_PADDING  ((psa_status_t)-150)</span>
</pre></div>
</div>
<p>The decrypted padding is incorrect.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">In some protocols, when decrypting data, it is essential that the behavior of the application does not depend on whether the padding is correct, down to precise timing. Applications should prefer protocols that use authenticated encryption rather than plain encryption. If the application must perform a decryption of unauthenticated data, the application writer should take care not to reveal whether the padding is invalid.</p>
</div>
<p>Implementations should strive to make valid and invalid padding as close as possible to indistinguishable to an external observer. In particular, the timing of a decryption operation should not depend on the validity of the padding.</p>
</div>
<div class="section" id="PSA_ERROR_INSUFFICIENT_DATA">
<span id="c.PSA_ERROR_INSUFFICIENT_DATA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_DATA</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INSUFFICIENT_DATA  ((psa_status_t)-143)</span>
</pre></div>
</div>
<p>Return this error when there’s insufficient data when attempting to read from a resource.</p>
</div>
<div class="section" id="PSA_ERROR_INVALID_HANDLE">
<span id="c.PSA_ERROR_INVALID_HANDLE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ERROR_INVALID_HANDLE  ((psa_status_t)-136)</span>
</pre></div>
</div>
<p>The key handle is not valid.</p>
</div>
</div>
<div class="section" id="key-and-algorithm-types">
<h1>Key and algorithm types</h1>
<div class="section" id="psa_key_type_t">
<span id="c.psa_key_type_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_type_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint32_t</span> <span class="n">psa_key_type_t</span><span class="p">;</span>
</pre></div>
</div>
<p>Encoding of a key type.</p>
</div>
<div class="section" id="psa_ecc_curve_t">
<span id="c.psa_ecc_curve_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_ecc_curve_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint16_t</span> <span class="n">psa_ecc_curve_t</span><span class="p">;</span>
</pre></div>
</div>
<p>The type of PSA elliptic curve identifiers.</p>
</div>
<div class="section" id="psa_dh_group_t">
<span id="c.psa_dh_group_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_dh_group_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint16_t</span> <span class="n">psa_dh_group_t</span><span class="p">;</span>
</pre></div>
</div>
<p>The type of PSA Diffie-Hellman group identifiers.</p>
</div>
<div class="section" id="psa_algorithm_t">
<span id="c.psa_algorithm_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint32_t</span> <span class="n">psa_algorithm_t</span><span class="p">;</span>
</pre></div>
</div>
<p>Encoding of a cryptographic algorithm.</p>
<p>For algorithms that can be applied to multiple key types, this type does not encode the key type. For example, for symmetric ciphers based on a block cipher, <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a> encodes the block cipher mode and the padding mode while the block cipher itself is encoded via <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_NONE">
<span id="c.PSA_KEY_TYPE_NONE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_NONE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_NONE  ((psa_key_type_t)0x00000000)</span>
</pre></div>
</div>
<p>An invalid key type value.</p>
<p>Zero is not the encoding of any key type.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_VENDOR_FLAG">
<span id="c.PSA_KEY_TYPE_VENDOR_FLAG"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_VENDOR_FLAG</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_VENDOR_FLAG  ((psa_key_type_t)0x80000000)</span>
</pre></div>
</div>
<p>Vendor-defined flag.</p>
<p>Key types defined by this standard will never have the <a class="reference internal" href="#c.PSA_KEY_TYPE_VENDOR_FLAG" title="PSA_KEY_TYPE_VENDOR_FLAG"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_VENDOR_FLAG</span></code></a> bit set. Vendors who define additional key types must use an encoding with the <a class="reference internal" href="#c.PSA_KEY_TYPE_VENDOR_FLAG" title="PSA_KEY_TYPE_VENDOR_FLAG"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_VENDOR_FLAG</span></code></a> bit set and should respect the bitwise structure used by standard encodings whenever practical.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_CATEGORY_MASK">
<span id="c.PSA_KEY_TYPE_CATEGORY_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_MASK</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CATEGORY_MASK  ((psa_key_type_t)0x70000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_KEY_TYPE_CATEGORY_SYMMETRIC">
<span id="c.PSA_KEY_TYPE_CATEGORY_SYMMETRIC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_SYMMETRIC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CATEGORY_SYMMETRIC  ((psa_key_type_t)0x40000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_KEY_TYPE_CATEGORY_RAW">
<span id="c.PSA_KEY_TYPE_CATEGORY_RAW"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_RAW</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CATEGORY_RAW  ((psa_key_type_t)0x50000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY  ((psa_key_type_t)0x60000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_KEY_TYPE_CATEGORY_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_CATEGORY_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_KEY_PAIR</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CATEGORY_KEY_PAIR  ((psa_key_type_t)0x70000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_KEY_TYPE_CATEGORY_FLAG_PAIR">
<span id="c.PSA_KEY_TYPE_CATEGORY_FLAG_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_FLAG_PAIR</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CATEGORY_FLAG_PAIR  ((psa_key_type_t)0x10000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_VENDOR_DEFINED">
<span id="c.PSA_KEY_TYPE_IS_VENDOR_DEFINED"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_VENDOR_DEFINED</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_VENDOR_DEFINED(type) \</span>
<span class="cp">    (((type) &amp; PSA_KEY_TYPE_VENDOR_FLAG) != 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether a key type is vendor-defined.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_UNSTRUCTURED">
<span id="c.PSA_KEY_TYPE_IS_UNSTRUCTURED"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_UNSTRUCTURED</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_UNSTRUCTURED(type) \</span>
<span class="cp">    (((type) &amp; PSA_KEY_TYPE_CATEGORY_MASK &amp; ~(psa_key_type_t)0x10000000) == PSA_KEY_TYPE_CATEGORY_SYMMETRIC)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether a key type is an unstructured array of bytes.</p>
<p>This encompasses both symmetric keys and non-key data.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_ASYMMETRIC">
<span id="c.PSA_KEY_TYPE_IS_ASYMMETRIC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ASYMMETRIC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_ASYMMETRIC(type) \</span>
<span class="cp">    (((type) &amp; PSA_KEY_TYPE_CATEGORY_MASK &amp; ~PSA_KEY_TYPE_CATEGORY_FLAG_PAIR) == PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether a key type is asymmetric: either a key pair or a public key.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_IS_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_PUBLIC_KEY</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_PUBLIC_KEY(type) \</span>
<span class="cp">    (((type) &amp; PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether a key type is the public part of a key pair.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_IS_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_KEY_PAIR</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_KEY_PAIR(type) \</span>
<span class="cp">    (((type) &amp; PSA_KEY_TYPE_CATEGORY_MASK) == PSA_KEY_TYPE_CATEGORY_KEY_PAIR)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether a key type is a key pair containing a private part and a public part.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY(type) \</span>
<span class="cp">    ((type) | PSA_KEY_TYPE_CATEGORY_FLAG_PAIR)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd>A public key type or key pair type.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding key pair type. If <code class="docutils literal notranslate"><span class="pre">type</span></code> is not a public key or a key pair, the return value is undefined.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>The key pair type corresponding to a public key type.</p>
<p>You may also pass a key pair type as <code class="docutils literal notranslate"><span class="pre">type</span></code>, it will be left unchanged.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) \</span>
<span class="cp">    ((type) &amp; ~PSA_KEY_TYPE_CATEGORY_FLAG_PAIR)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd>A public key type or key pair type.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding public key type. If <code class="docutils literal notranslate"><span class="pre">type</span></code> is not a public key or a key pair, the return value is undefined.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>The public key type corresponding to a key pair type.</p>
<p>You may also pass a key pair type as <code class="docutils literal notranslate"><span class="pre">type</span></code>, it will be left unchanged.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_RAW_DATA">
<span id="c.PSA_KEY_TYPE_RAW_DATA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RAW_DATA</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_RAW_DATA  ((psa_key_type_t)0x50000001)</span>
</pre></div>
</div>
<p>Raw data.</p>
<p>A “key” of this type cannot be used for any cryptographic operation. Applications may use this type to store arbitrary data in the keystore.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_HMAC">
<span id="c.PSA_KEY_TYPE_HMAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_HMAC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_HMAC  ((psa_key_type_t)0x51000000)</span>
</pre></div>
</div>
<p>HMAC key.</p>
<p>The key policy determines which underlying hash algorithm the key can be used for.</p>
<p>HMAC keys should generally have the same size as the underlying hash. This size can be calculated with <a class="reference internal" href="#c.PSA_HASH_SIZE" title="PSA_HASH_SIZE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_HASH_SIZE</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">alg</span></code> is the HMAC algorithm or the underlying hash algorithm.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_DERIVE">
<span id="c.PSA_KEY_TYPE_DERIVE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DERIVE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_DERIVE  ((psa_key_type_t)0x52000000)</span>
</pre></div>
</div>
<p>A secret for key derivation.</p>
<p>The key policy determines which key derivation algorithm the key can be used for.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_AES">
<span id="c.PSA_KEY_TYPE_AES"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_AES</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_AES  ((psa_key_type_t)0x40000001)</span>
</pre></div>
</div>
<p>Key for a cipher, AEAD or MAC algorithm based on the AES block cipher.</p>
<p>The size of the key can be 16 bytes (AES-128), 24 bytes (AES-192) or 32 bytes (AES-256).</p>
</div>
<div class="section" id="PSA_KEY_TYPE_DES">
<span id="c.PSA_KEY_TYPE_DES"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DES</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_DES  ((psa_key_type_t)0x40000002)</span>
</pre></div>
</div>
<p>Key for a cipher or MAC algorithm based on DES or 3DES (Triple-DES).</p>
<p>The size of the key can be 8 bytes (single DES), 16 bytes (2-key 3DES) or 24 bytes (3-key 3DES).</p>
<p>Note that single DES and 2-key 3DES are weak and strongly deprecated and should only be used to decrypt legacy data. 3-key 3DES is weak and deprecated and should only be used in legacy protocols.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_CAMELLIA">
<span id="c.PSA_KEY_TYPE_CAMELLIA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CAMELLIA</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CAMELLIA  ((psa_key_type_t)0x40000003)</span>
</pre></div>
</div>
<p>Key for a cipher, AEAD or MAC algorithm based on the Camellia block cipher.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_ARC4">
<span id="c.PSA_KEY_TYPE_ARC4"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ARC4</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_ARC4  ((psa_key_type_t)0x40000004)</span>
</pre></div>
</div>
<p>Key for the RC4 stream cipher.</p>
<p>Note that RC4 is weak and deprecated and should only be used in legacy protocols.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_CHACHA20">
<span id="c.PSA_KEY_TYPE_CHACHA20"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CHACHA20</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_CHACHA20  ((psa_key_type_t)0x40000005)</span>
</pre></div>
</div>
<p>Key for the ChaCha20 stream cipher or the Chacha20-Poly1305 AEAD algorithm.</p>
<p>ChaCha20 and the ChaCha20_Poly1305 construction are defined in RFC 7539.</p>
<p>Implementations must support 12-byte nonces, may support 8-byte nonces, and should reject other sizes.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_RSA_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_RSA_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_PUBLIC_KEY</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_RSA_PUBLIC_KEY  ((psa_key_type_t)0x60010000)</span>
</pre></div>
</div>
<p>RSA public key.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_RSA_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_RSA_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_KEY_PAIR</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_RSA_KEY_PAIR  ((psa_key_type_t)0x70010000)</span>
</pre></div>
</div>
<p>RSA key pair (private and public key).</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_RSA">
<span id="c.PSA_KEY_TYPE_IS_RSA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_RSA</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_RSA(type) \</span>
<span class="cp">    (PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) == PSA_KEY_TYPE_RSA_PUBLIC_KEY)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether a key type is an RSA key (pair or public-only).</p>
</div>
<div class="section" id="PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE">
<span id="c.PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE  ((psa_key_type_t)0x60030000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_KEY_TYPE_ECC_KEY_PAIR_BASE">
<span id="c.PSA_KEY_TYPE_ECC_KEY_PAIR_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_ECC_KEY_PAIR_BASE  ((psa_key_type_t)0x70030000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_KEY_TYPE_ECC_CURVE_MASK">
<span id="c.PSA_KEY_TYPE_ECC_CURVE_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_CURVE_MASK</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_ECC_CURVE_MASK  ((psa_key_type_t)0x0000ffff)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_KEY_TYPE_ECC_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_ECC_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_ECC_KEY_PAIR(curve) \</span>
<span class="cp">    (PSA_KEY_TYPE_ECC_KEY_PAIR_BASE | (curve))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">curve</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Elliptic curve key pair.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_ECC_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_ECC_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_PUBLIC_KEY</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_ECC_PUBLIC_KEY(curve) \</span>
<span class="cp">    (PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE | (curve))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">curve</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Elliptic curve public key.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_ECC">
<span id="c.PSA_KEY_TYPE_IS_ECC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_ECC(type) \</span>
<span class="cp">    ((PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) &amp; ~PSA_KEY_TYPE_ECC_CURVE_MASK) == PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether a key type is an elliptic curve key (pair or public-only).</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_ECC_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_IS_ECC_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC_KEY_PAIR</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_ECC_KEY_PAIR(type) \</span>
<span class="cp">    (((type) &amp; ~PSA_KEY_TYPE_ECC_CURVE_MASK) == PSA_KEY_TYPE_ECC_KEY_PAIR_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether a key type is an elliptic curve key pair.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(type) \</span>
<span class="cp">    (((type) &amp; ~PSA_KEY_TYPE_ECC_CURVE_MASK) == PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether a key type is an elliptic curve public key.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_GET_CURVE">
<span id="c.PSA_KEY_TYPE_GET_CURVE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_GET_CURVE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_GET_CURVE(type) \</span>
<span class="cp">    ((psa_ecc_curve_t) (PSA_KEY_TYPE_IS_ECC(type) ? ((type) &amp; PSA_KEY_TYPE_ECC_CURVE_MASK) : 0))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Extract the curve from an elliptic curve key type.</p>
</div>
<div class="section" id="PSA_ECC_CURVE_SECT163K1">
<span id="c.PSA_ECC_CURVE_SECT163K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT163K1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT163K1  ((psa_ecc_curve_t) 0x0001)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECT163R1">
<span id="c.PSA_ECC_CURVE_SECT163R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT163R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT163R1  ((psa_ecc_curve_t) 0x0002)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECT163R2">
<span id="c.PSA_ECC_CURVE_SECT163R2"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT163R2</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT163R2  ((psa_ecc_curve_t) 0x0003)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECT193R1">
<span id="c.PSA_ECC_CURVE_SECT193R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT193R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT193R1  ((psa_ecc_curve_t) 0x0004)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECT193R2">
<span id="c.PSA_ECC_CURVE_SECT193R2"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT193R2</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT193R2  ((psa_ecc_curve_t) 0x0005)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECT233K1">
<span id="c.PSA_ECC_CURVE_SECT233K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT233K1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT233K1  ((psa_ecc_curve_t) 0x0006)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECT233R1">
<span id="c.PSA_ECC_CURVE_SECT233R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT233R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT233R1  ((psa_ecc_curve_t) 0x0007)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECT239K1">
<span id="c.PSA_ECC_CURVE_SECT239K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT239K1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT239K1  ((psa_ecc_curve_t) 0x0008)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECT283K1">
<span id="c.PSA_ECC_CURVE_SECT283K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT283K1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT283K1  ((psa_ecc_curve_t) 0x0009)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECT283R1">
<span id="c.PSA_ECC_CURVE_SECT283R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT283R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT283R1  ((psa_ecc_curve_t) 0x000a)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECT409K1">
<span id="c.PSA_ECC_CURVE_SECT409K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT409K1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT409K1  ((psa_ecc_curve_t) 0x000b)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECT409R1">
<span id="c.PSA_ECC_CURVE_SECT409R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT409R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT409R1  ((psa_ecc_curve_t) 0x000c)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECT571K1">
<span id="c.PSA_ECC_CURVE_SECT571K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT571K1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT571K1  ((psa_ecc_curve_t) 0x000d)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECT571R1">
<span id="c.PSA_ECC_CURVE_SECT571R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT571R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECT571R1  ((psa_ecc_curve_t) 0x000e)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECP160K1">
<span id="c.PSA_ECC_CURVE_SECP160K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP160K1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP160K1  ((psa_ecc_curve_t) 0x000f)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECP160R1">
<span id="c.PSA_ECC_CURVE_SECP160R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP160R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP160R1  ((psa_ecc_curve_t) 0x0010)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECP160R2">
<span id="c.PSA_ECC_CURVE_SECP160R2"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP160R2</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP160R2  ((psa_ecc_curve_t) 0x0011)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECP192K1">
<span id="c.PSA_ECC_CURVE_SECP192K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP192K1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP192K1  ((psa_ecc_curve_t) 0x0012)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECP192R1">
<span id="c.PSA_ECC_CURVE_SECP192R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP192R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP192R1  ((psa_ecc_curve_t) 0x0013)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECP224K1">
<span id="c.PSA_ECC_CURVE_SECP224K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP224K1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP224K1  ((psa_ecc_curve_t) 0x0014)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECP224R1">
<span id="c.PSA_ECC_CURVE_SECP224R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP224R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP224R1  ((psa_ecc_curve_t) 0x0015)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECP256K1">
<span id="c.PSA_ECC_CURVE_SECP256K1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP256K1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP256K1  ((psa_ecc_curve_t) 0x0016)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECP256R1">
<span id="c.PSA_ECC_CURVE_SECP256R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP256R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP256R1  ((psa_ecc_curve_t) 0x0017)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECP384R1">
<span id="c.PSA_ECC_CURVE_SECP384R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP384R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP384R1  ((psa_ecc_curve_t) 0x0018)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_SECP521R1">
<span id="c.PSA_ECC_CURVE_SECP521R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP521R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_SECP521R1  ((psa_ecc_curve_t) 0x0019)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_BRAINPOOL_P256R1">
<span id="c.PSA_ECC_CURVE_BRAINPOOL_P256R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_P256R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_BRAINPOOL_P256R1  ((psa_ecc_curve_t) 0x001a)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_BRAINPOOL_P384R1">
<span id="c.PSA_ECC_CURVE_BRAINPOOL_P384R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_P384R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_BRAINPOOL_P384R1  ((psa_ecc_curve_t) 0x001b)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_BRAINPOOL_P512R1">
<span id="c.PSA_ECC_CURVE_BRAINPOOL_P512R1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_P512R1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_BRAINPOOL_P512R1  ((psa_ecc_curve_t) 0x001c)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_CURVE25519">
<span id="c.PSA_ECC_CURVE_CURVE25519"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVE25519</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_CURVE25519  ((psa_ecc_curve_t) 0x001d)</span>
</pre></div>
</div>
<p>Curve25519.</p>
<p>This is the curve defined in Bernstein et al., <em>Curve25519: new Diffie-Hellman speed records</em>, LNCS 3958, 2006. The algorithm <a class="reference internal" href="#c.PSA_ALG_ECDH" title="PSA_ALG_ECDH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDH</span></code></a> performs X25519 when used with this curve.</p>
</div>
<div class="section" id="PSA_ECC_CURVE_CURVE448">
<span id="c.PSA_ECC_CURVE_CURVE448"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVE448</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_CURVE448  ((psa_ecc_curve_t) 0x001e)</span>
</pre></div>
</div>
<p>Curve448.</p>
<p>This is the curve defined in Hamburg, <em>Ed448-Goldilocks, a new elliptic curve</em>, NIST ECC Workshop, 2015. The algorithm <a class="reference internal" href="#c.PSA_ALG_ECDH" title="PSA_ALG_ECDH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDH</span></code></a> performs X448 when used with this curve.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE">
<span id="c.PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE  ((psa_key_type_t)0x60040000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_KEY_TYPE_DH_KEY_PAIR_BASE">
<span id="c.PSA_KEY_TYPE_DH_KEY_PAIR_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_KEY_PAIR_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_DH_KEY_PAIR_BASE  ((psa_key_type_t)0x70040000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_KEY_TYPE_DH_GROUP_MASK">
<span id="c.PSA_KEY_TYPE_DH_GROUP_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_GROUP_MASK</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_DH_GROUP_MASK  ((psa_key_type_t)0x0000ffff)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_KEY_TYPE_DH_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_DH_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_KEY_PAIR</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_DH_KEY_PAIR(group) \</span>
<span class="cp">    (PSA_KEY_TYPE_DH_KEY_PAIR_BASE | (group))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">group</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Diffie-Hellman key pair.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_DH_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_DH_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_PUBLIC_KEY</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_DH_PUBLIC_KEY(group) \</span>
<span class="cp">    (PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE | (group))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">group</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Diffie-Hellman public key.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_DH">
<span id="c.PSA_KEY_TYPE_IS_DH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_DH(type) \</span>
<span class="cp">    ((PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR(type) &amp; ~PSA_KEY_TYPE_DH_GROUP_MASK) == PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether a key type is a Diffie-Hellman key (pair or public-only).</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_DH_KEY_PAIR">
<span id="c.PSA_KEY_TYPE_IS_DH_KEY_PAIR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH_KEY_PAIR</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_DH_KEY_PAIR(type) \</span>
<span class="cp">    (((type) &amp; ~PSA_KEY_TYPE_DH_GROUP_MASK) == PSA_KEY_TYPE_DH_KEY_PAIR_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether a key type is a Diffie-Hellman key pair.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_IS_DH_PUBLIC_KEY">
<span id="c.PSA_KEY_TYPE_IS_DH_PUBLIC_KEY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH_PUBLIC_KEY</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_IS_DH_PUBLIC_KEY(type) \</span>
<span class="cp">    (((type) &amp; ~PSA_KEY_TYPE_DH_GROUP_MASK) == PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether a key type is a Diffie-Hellman public key.</p>
</div>
<div class="section" id="PSA_KEY_TYPE_GET_GROUP">
<span id="c.PSA_KEY_TYPE_GET_GROUP"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_GET_GROUP</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_TYPE_GET_GROUP(type) \</span>
<span class="cp">    ((psa_dh_group_t) (PSA_KEY_TYPE_IS_DH(type) ? ((type) &amp; PSA_KEY_TYPE_DH_GROUP_MASK) : 0))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Extract the group from a Diffie-Hellman key type.</p>
</div>
<div class="section" id="PSA_DH_GROUP_FFDHE2048">
<span id="c.PSA_DH_GROUP_FFDHE2048"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE2048</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_DH_GROUP_FFDHE2048  ((psa_dh_group_t) 0x0100)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_DH_GROUP_FFDHE3072">
<span id="c.PSA_DH_GROUP_FFDHE3072"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE3072</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_DH_GROUP_FFDHE3072  ((psa_dh_group_t) 0x0101)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_DH_GROUP_FFDHE4096">
<span id="c.PSA_DH_GROUP_FFDHE4096"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE4096</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_DH_GROUP_FFDHE4096  ((psa_dh_group_t) 0x0102)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_DH_GROUP_FFDHE6144">
<span id="c.PSA_DH_GROUP_FFDHE6144"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE6144</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_DH_GROUP_FFDHE6144  ((psa_dh_group_t) 0x0103)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_DH_GROUP_FFDHE8192">
<span id="c.PSA_DH_GROUP_FFDHE8192"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE8192</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_DH_GROUP_FFDHE8192  ((psa_dh_group_t) 0x0104)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_BLOCK_CIPHER_BLOCK_SIZE">
<span id="c.PSA_BLOCK_CIPHER_BLOCK_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_BLOCK_CIPHER_BLOCK_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_BLOCK_CIPHER_BLOCK_SIZE(type) \</span>
<span class="cp">    ( (type) == PSA_KEY_TYPE_AES ? 16 : (type) == PSA_KEY_TYPE_DES ? 8 : (type) == PSA_KEY_TYPE_CAMELLIA ? 16 : (type) == PSA_KEY_TYPE_ARC4 ? 1 : 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">type</span></code></dt>
<dd>A cipher key type (value of type <a class="reference internal" href="#c.psa_key_type_t" title="psa_key_type_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_type_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The block size for a block cipher, or 1 for a stream cipher. The return value is undefined if <code class="docutils literal notranslate"><span class="pre">type</span></code> is not a supported cipher key type.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>The block size of a block cipher.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">It is possible to build stream cipher algorithms on top of a block cipher, for example CTR mode (<a class="reference internal" href="#c.PSA_ALG_CTR" title="PSA_ALG_CTR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_CTR</span></code></a>). This macro only takes the key type into account, so it cannot be used to determine the size of the data that <a class="reference internal" href="#c.psa_cipher_update" title="psa_cipher_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_update()</span></code></a> might buffer for future processing in general.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This macro returns a compile-time constant if its argument is one.</p>
</div>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">This macro may evaluate its argument multiple times.</p>
</div>
</div>
<div class="section" id="PSA_ALG_VENDOR_FLAG">
<span id="c.PSA_ALG_VENDOR_FLAG"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_VENDOR_FLAG</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_VENDOR_FLAG  ((psa_algorithm_t)0x80000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_CATEGORY_MASK">
<span id="c.PSA_ALG_CATEGORY_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_MASK</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_MASK  ((psa_algorithm_t)0x7f000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_CATEGORY_HASH">
<span id="c.PSA_ALG_CATEGORY_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_HASH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_HASH  ((psa_algorithm_t)0x01000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_CATEGORY_MAC">
<span id="c.PSA_ALG_CATEGORY_MAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_MAC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_MAC  ((psa_algorithm_t)0x02000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_CATEGORY_CIPHER">
<span id="c.PSA_ALG_CATEGORY_CIPHER"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_CIPHER</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_CIPHER  ((psa_algorithm_t)0x04000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_CATEGORY_AEAD">
<span id="c.PSA_ALG_CATEGORY_AEAD"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_AEAD</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_AEAD  ((psa_algorithm_t)0x06000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_CATEGORY_SIGN">
<span id="c.PSA_ALG_CATEGORY_SIGN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_SIGN</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_SIGN  ((psa_algorithm_t)0x10000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION">
<span id="c.PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION  ((psa_algorithm_t)0x12000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_CATEGORY_KEY_DERIVATION">
<span id="c.PSA_ALG_CATEGORY_KEY_DERIVATION"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_KEY_DERIVATION</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_KEY_DERIVATION  ((psa_algorithm_t)0x20000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_CATEGORY_KEY_AGREEMENT">
<span id="c.PSA_ALG_CATEGORY_KEY_AGREEMENT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_KEY_AGREEMENT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CATEGORY_KEY_AGREEMENT  ((psa_algorithm_t)0x30000000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_IS_VENDOR_DEFINED">
<span id="c.PSA_ALG_IS_VENDOR_DEFINED"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_VENDOR_DEFINED</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_VENDOR_DEFINED(alg)  (((alg) &amp; PSA_ALG_VENDOR_FLAG) != 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_IS_HASH">
<span id="c.PSA_ALG_IS_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_HASH(alg) \</span>
<span class="cp">    (((alg) &amp; PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_HASH)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a hash algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is a hash algorithm.</p>
</div>
<div class="section" id="PSA_ALG_IS_MAC">
<span id="c.PSA_ALG_IS_MAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_MAC(alg) \</span>
<span class="cp">    (((alg) &amp; PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_MAC)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a MAC algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is a MAC algorithm.</p>
</div>
<div class="section" id="PSA_ALG_IS_CIPHER">
<span id="c.PSA_ALG_IS_CIPHER"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_CIPHER</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_CIPHER(alg) \</span>
<span class="cp">    (((alg) &amp; PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_CIPHER)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a symmetric cipher algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is a symmetric cipher algorithm.</p>
</div>
<div class="section" id="PSA_ALG_IS_AEAD">
<span id="c.PSA_ALG_IS_AEAD"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_AEAD(alg) \</span>
<span class="cp">    (((alg) &amp; PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_AEAD)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is an AEAD algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is an authenticated encryption with associated data (AEAD) algorithm.</p>
</div>
<div class="section" id="PSA_ALG_IS_SIGN">
<span id="c.PSA_ALG_IS_SIGN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_SIGN</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_SIGN(alg) \</span>
<span class="cp">    (((alg) &amp; PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_SIGN)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a public-key signature algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is a public-key signature algorithm.</p>
</div>
<div class="section" id="PSA_ALG_IS_ASYMMETRIC_ENCRYPTION">
<span id="c.PSA_ALG_IS_ASYMMETRIC_ENCRYPTION"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_ASYMMETRIC_ENCRYPTION</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_ASYMMETRIC_ENCRYPTION(alg) \</span>
<span class="cp">    (((alg) &amp; PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a public-key encryption algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is a public-key encryption algorithm.</p>
</div>
<div class="section" id="PSA_ALG_IS_KEY_AGREEMENT">
<span id="c.PSA_ALG_IS_KEY_AGREEMENT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_AGREEMENT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_KEY_AGREEMENT(alg) \</span>
<span class="cp">    (((alg) &amp; PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_KEY_AGREEMENT)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a key agreement algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is a key agreement algorithm.</p>
</div>
<div class="section" id="PSA_ALG_IS_KEY_DERIVATION">
<span id="c.PSA_ALG_IS_KEY_DERIVATION"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_DERIVATION</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_KEY_DERIVATION(alg) \</span>
<span class="cp">    (((alg) &amp; PSA_ALG_CATEGORY_MASK) == PSA_ALG_CATEGORY_KEY_DERIVATION)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a key derivation algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is a key derivation algorithm.</p>
</div>
<div class="section" id="PSA_ALG_HASH_MASK">
<span id="c.PSA_ALG_HASH_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HASH_MASK</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_HASH_MASK  ((psa_algorithm_t)0x000000ff)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_MD2">
<span id="c.PSA_ALG_MD2"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MD2</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_MD2  ((psa_algorithm_t)0x01000001)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_MD4">
<span id="c.PSA_ALG_MD4"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MD4</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_MD4  ((psa_algorithm_t)0x01000002)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_MD5">
<span id="c.PSA_ALG_MD5"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MD5</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_MD5  ((psa_algorithm_t)0x01000003)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_RIPEMD160">
<span id="c.PSA_ALG_RIPEMD160"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RIPEMD160</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RIPEMD160  ((psa_algorithm_t)0x01000004)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_SHA_1">
<span id="c.PSA_ALG_SHA_1"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_1</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA_1  ((psa_algorithm_t)0x01000005)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_SHA_224">
<span id="c.PSA_ALG_SHA_224"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_224</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA_224  ((psa_algorithm_t)0x01000008)</span>
</pre></div>
</div>
<p>SHA2-224.</p>
</div>
<div class="section" id="PSA_ALG_SHA_256">
<span id="c.PSA_ALG_SHA_256"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_256</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA_256  ((psa_algorithm_t)0x01000009)</span>
</pre></div>
</div>
<p>SHA2-256.</p>
</div>
<div class="section" id="PSA_ALG_SHA_384">
<span id="c.PSA_ALG_SHA_384"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_384</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA_384  ((psa_algorithm_t)0x0100000a)</span>
</pre></div>
</div>
<p>SHA2-384.</p>
</div>
<div class="section" id="PSA_ALG_SHA_512">
<span id="c.PSA_ALG_SHA_512"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_512</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA_512  ((psa_algorithm_t)0x0100000b)</span>
</pre></div>
</div>
<p>SHA2-512.</p>
</div>
<div class="section" id="PSA_ALG_SHA_512_224">
<span id="c.PSA_ALG_SHA_512_224"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_512_224</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA_512_224  ((psa_algorithm_t)0x0100000c)</span>
</pre></div>
</div>
<p>SHA2-512/224.</p>
</div>
<div class="section" id="PSA_ALG_SHA_512_256">
<span id="c.PSA_ALG_SHA_512_256"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_512_256</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA_512_256  ((psa_algorithm_t)0x0100000d)</span>
</pre></div>
</div>
<p>SHA2-512/256.</p>
</div>
<div class="section" id="PSA_ALG_SHA3_224">
<span id="c.PSA_ALG_SHA3_224"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_224</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA3_224  ((psa_algorithm_t)0x01000010)</span>
</pre></div>
</div>
<p>SHA3-224.</p>
</div>
<div class="section" id="PSA_ALG_SHA3_256">
<span id="c.PSA_ALG_SHA3_256"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_256</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA3_256  ((psa_algorithm_t)0x01000011)</span>
</pre></div>
</div>
<p>SHA3-256.</p>
</div>
<div class="section" id="PSA_ALG_SHA3_384">
<span id="c.PSA_ALG_SHA3_384"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_384</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA3_384  ((psa_algorithm_t)0x01000012)</span>
</pre></div>
</div>
<p>SHA3-384.</p>
</div>
<div class="section" id="PSA_ALG_SHA3_512">
<span id="c.PSA_ALG_SHA3_512"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_512</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SHA3_512  ((psa_algorithm_t)0x01000013)</span>
</pre></div>
</div>
<p>SHA3-512.</p>
</div>
<div class="section" id="PSA_ALG_ANY_HASH">
<span id="c.PSA_ALG_ANY_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ANY_HASH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_ANY_HASH  ((psa_algorithm_t)0x010000ff)</span>
</pre></div>
</div>
<p>In a hash-and-sign algorithm policy, allow any hash algorithm.</p>
<p>This value may be used to form the algorithm usage field of a policy for a signature algorithm that is parametrized by a hash. The key may then be used to perform operations using the same signature algorithm parametrized with any supported hash.</p>
<p>That is, suppose that <code class="docutils literal notranslate"><span class="pre">PSA_xxx_SIGNATURE</span></code> is one of the following macros:</p>
<ul>
<li><p class="first"><a class="reference internal" href="#c.PSA_ALG_RSA_PKCS1V15_SIGN" title="PSA_ALG_RSA_PKCS1V15_SIGN"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN</span></code></a>, <a class="reference internal" href="#c.PSA_ALG_RSA_PSS" title="PSA_ALG_RSA_PSS"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PSS</span></code></a>,</p>
</li>
<li><p class="first"><a class="reference internal" href="#c.PSA_ALG_ECDSA" title="PSA_ALG_ECDSA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA</span></code></a>, <a class="reference internal" href="#c.PSA_ALG_DETERMINISTIC_ECDSA" title="PSA_ALG_DETERMINISTIC_ECDSA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_DETERMINISTIC_ECDSA</span></code></a>. Then you may create and use a key as follows:</p>
</li>
<li><p class="first">Set the key usage field using <a class="reference internal" href="#c.PSA_ALG_ANY_HASH" title="PSA_ALG_ANY_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ANY_HASH</span></code></a>, for example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_set_key_usage_flags</span><span class="p">(</span><span class="o">&amp;</span><span class="n">attributes</span><span class="p">,</span> <span class="n">PSA_KEY_USAGE_SIGN</span><span class="p">);</span> <span class="c1">// or VERIFY</span>
<span class="n">psa_set_key_algorithm</span><span class="p">(</span><span class="o">&amp;</span><span class="n">attributes</span><span class="p">,</span> <span class="n">PSA_xxx_SIGNATURE</span><span class="p">(</span><span class="n">PSA_ALG_ANY_HASH</span><span class="p">));</span>
</pre></div>
</div>
</li>
<li><p class="first">Import or generate key material.</p>
</li>
<li><p class="first">Call <a class="reference internal" href="#c.psa_asymmetric_sign" title="psa_asymmetric_sign"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_sign()</span></code></a> or <a class="reference internal" href="#c.psa_asymmetric_verify" title="psa_asymmetric_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_verify()</span></code></a>, passing an algorithm built from <code class="docutils literal notranslate"><span class="pre">PSA_xxx_SIGNATURE</span></code> and a specific hash. Each call to sign or verify a message may use a different hash.</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_asymmetric_sign</span><span class="p">(</span><span class="n">handle</span><span class="p">,</span> <span class="n">PSA_xxx_SIGNATURE</span><span class="p">(</span><span class="n">PSA_ALG_SHA_256</span><span class="p">),</span> <span class="p">...);</span>
<span class="n">psa_asymmetric_sign</span><span class="p">(</span><span class="n">handle</span><span class="p">,</span> <span class="n">PSA_xxx_SIGNATURE</span><span class="p">(</span><span class="n">PSA_ALG_SHA_512</span><span class="p">),</span> <span class="p">...);</span>
<span class="n">psa_asymmetric_sign</span><span class="p">(</span><span class="n">handle</span><span class="p">,</span> <span class="n">PSA_xxx_SIGNATURE</span><span class="p">(</span><span class="n">PSA_ALG_SHA3_256</span><span class="p">),</span> <span class="p">...);</span>
</pre></div>
</div>
</li>
</ul>
<p>This value may not be used to build other algorithms that are parametrized over a hash. For any valid use of this macro to build an algorithm <code class="docutils literal notranslate"><span class="pre">alg</span></code>, <a class="reference internal" href="#c.PSA_ALG_IS_HASH_AND_SIGN" title="PSA_ALG_IS_HASH_AND_SIGN"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH_AND_SIGN</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true.</p>
<p>This value may not be used to build an algorithm specification to perform an operation. It is only valid to build policies.</p>
</div>
<div class="section" id="PSA_ALG_MAC_SUBCATEGORY_MASK">
<span id="c.PSA_ALG_MAC_SUBCATEGORY_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MAC_SUBCATEGORY_MASK</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_MAC_SUBCATEGORY_MASK  ((psa_algorithm_t)0x00c00000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_HMAC_BASE">
<span id="c.PSA_ALG_HMAC_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HMAC_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_HMAC_BASE  ((psa_algorithm_t)0x02800000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_HMAC">
<span id="c.PSA_ALG_HMAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HMAC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_HMAC(hash_alg) \</span>
<span class="cp">    (PSA_ALG_HMAC_BASE | ((hash_alg) &amp; PSA_ALG_HASH_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt>
<dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding HMAC algorithm.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Macro to build an HMAC algorithm.</p>
<p>For example, <a class="reference internal" href="#c.PSA_ALG_HMAC" title="PSA_ALG_HMAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_HMAC</span></code></a>(<a class="reference internal" href="#c.PSA_ALG_SHA_256" title="PSA_ALG_SHA_256"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_SHA_256</span></code></a>) is HMAC-SHA-256.</p>
</div>
<div class="section" id="PSA_ALG_HMAC_GET_HASH">
<span id="c.PSA_ALG_HMAC_GET_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HMAC_GET_HASH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_HMAC_GET_HASH(hmac_alg) \</span>
<span class="cp">    (PSA_ALG_CATEGORY_HASH | ((hmac_alg) &amp; PSA_ALG_HASH_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">hmac_alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_IS_HMAC">
<span id="c.PSA_ALG_IS_HMAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HMAC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_HMAC(alg) \</span>
<span class="cp">    (((alg) &amp; (PSA_ALG_CATEGORY_MASK | PSA_ALG_MAC_SUBCATEGORY_MASK)) == PSA_ALG_HMAC_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is an HMAC algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is an HMAC algorithm.</p>
<p>HMAC is a family of MAC algorithms that are based on a hash function.</p>
</div>
<div class="section" id="PSA_ALG_MAC_TRUNCATION_MASK">
<span id="c.PSA_ALG_MAC_TRUNCATION_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MAC_TRUNCATION_MASK</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_MAC_TRUNCATION_MASK  ((psa_algorithm_t)0x00003f00)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_MAC_TRUNCATION_OFFSET">
<span id="c.PSA_MAC_TRUNCATION_OFFSET"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_MAC_TRUNCATION_OFFSET</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_MAC_TRUNCATION_OFFSET  8</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_TRUNCATED_MAC">
<span id="c.PSA_ALG_TRUNCATED_MAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TRUNCATED_MAC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TRUNCATED_MAC(mac_alg, mac_length) \</span>
<span class="cp">    (((mac_alg) &amp; ~PSA_ALG_MAC_TRUNCATION_MASK) | ((mac_length) &lt;&lt; PSA_MAC_TRUNCATION_OFFSET &amp; PSA_ALG_MAC_TRUNCATION_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">mac_alg</span></code></dt>
<dd>A MAC algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a> such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true). This may be a truncated or untruncated MAC algorithm.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">mac_length</span></code></dt>
<dd>Desired length of the truncated MAC in bytes. This must be at most the full length of the MAC and must be at least an implementation-specified minimum. The implementation-specified minimum shall not be zero.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding MAC algorithm with the specified length.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported MAC algorithm or if <code class="docutils literal notranslate"><span class="pre">mac_length</span></code> is too small or too large for the specified MAC algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Macro to build a truncated MAC algorithm.</p>
<p>A truncated MAC algorithm is identical to the corresponding MAC algorithm except that the MAC value for the truncated algorithm consists of only the first <code class="docutils literal notranslate"><span class="pre">mac_length</span></code> bytes of the MAC value for the untruncated algorithm.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This macro may allow constructing algorithm identifiers that are not valid, either because the specified length is larger than the untruncated MAC or because the specified length is smaller than permitted by the implementation.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">It is implementation-defined whether a truncated MAC that is truncated to the same length as the MAC of the untruncated algorithm is considered identical to the untruncated algorithm for policy comparison purposes.</p>
</div>
</div>
<div class="section" id="PSA_ALG_FULL_LENGTH_MAC">
<span id="c.PSA_ALG_FULL_LENGTH_MAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_FULL_LENGTH_MAC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_FULL_LENGTH_MAC(mac_alg) \</span>
<span class="cp">    ((mac_alg) &amp; ~PSA_ALG_MAC_TRUNCATION_MASK)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">mac_alg</span></code></dt>
<dd>A MAC algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a> such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true). This may be a truncated or untruncated MAC algorithm.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding base MAC algorithm.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported MAC algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Macro to build the base MAC algorithm corresponding to a truncated MAC algorithm.</p>
</div>
<div class="section" id="PSA_MAC_TRUNCATED_LENGTH">
<span id="c.PSA_MAC_TRUNCATED_LENGTH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_MAC_TRUNCATED_LENGTH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_MAC_TRUNCATED_LENGTH(mac_alg) \</span>
<span class="cp">    (((mac_alg) &amp; PSA_ALG_MAC_TRUNCATION_MASK) &gt;&gt; PSA_MAC_TRUNCATION_OFFSET)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">mac_alg</span></code></dt>
<dd>A MAC algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a> such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>Length of the truncated MAC in bytes.</p>
<p>0 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a non-truncated MAC algorithm.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported MAC algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Length to which a MAC algorithm is truncated.</p>
</div>
<div class="section" id="PSA_ALG_CIPHER_MAC_BASE">
<span id="c.PSA_ALG_CIPHER_MAC_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CIPHER_MAC_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CIPHER_MAC_BASE  ((psa_algorithm_t)0x02c00000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_CBC_MAC">
<span id="c.PSA_ALG_CBC_MAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CBC_MAC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CBC_MAC  ((psa_algorithm_t)0x02c00001)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_CMAC">
<span id="c.PSA_ALG_CMAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CMAC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CMAC  ((psa_algorithm_t)0x02c00002)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_GMAC">
<span id="c.PSA_ALG_GMAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_GMAC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_GMAC  ((psa_algorithm_t)0x02c00003)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_IS_BLOCK_CIPHER_MAC">
<span id="c.PSA_ALG_IS_BLOCK_CIPHER_MAC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_BLOCK_CIPHER_MAC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_BLOCK_CIPHER_MAC(alg) \</span>
<span class="cp">    (((alg) &amp; (PSA_ALG_CATEGORY_MASK | PSA_ALG_MAC_SUBCATEGORY_MASK)) == PSA_ALG_CIPHER_MAC_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a MAC algorithm based on a block cipher, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is a MAC algorithm based on a block cipher.</p>
</div>
<div class="section" id="PSA_ALG_CIPHER_STREAM_FLAG">
<span id="c.PSA_ALG_CIPHER_STREAM_FLAG"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CIPHER_STREAM_FLAG</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CIPHER_STREAM_FLAG  ((psa_algorithm_t)0x00800000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_CIPHER_FROM_BLOCK_FLAG">
<span id="c.PSA_ALG_CIPHER_FROM_BLOCK_FLAG"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CIPHER_FROM_BLOCK_FLAG</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CIPHER_FROM_BLOCK_FLAG  ((psa_algorithm_t)0x00400000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_IS_STREAM_CIPHER">
<span id="c.PSA_ALG_IS_STREAM_CIPHER"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_STREAM_CIPHER</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_STREAM_CIPHER(alg) \</span>
<span class="cp">    (((alg) &amp; (PSA_ALG_CATEGORY_MASK | PSA_ALG_CIPHER_STREAM_FLAG)) == (PSA_ALG_CATEGORY_CIPHER | PSA_ALG_CIPHER_STREAM_FLAG))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a stream cipher algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier or if it is not a symmetric cipher algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is a stream cipher.</p>
<p>A stream cipher is a symmetric cipher that encrypts or decrypts messages by applying a bitwise-xor with a stream of bytes that is generated from a key.</p>
</div>
<div class="section" id="PSA_ALG_ARC4">
<span id="c.PSA_ALG_ARC4"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ARC4</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_ARC4  ((psa_algorithm_t)0x04800001)</span>
</pre></div>
</div>
<p>The ARC4 stream cipher algorithm.</p>
</div>
<div class="section" id="PSA_ALG_CHACHA20">
<span id="c.PSA_ALG_CHACHA20"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CHACHA20</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CHACHA20  ((psa_algorithm_t)0x04800005)</span>
</pre></div>
</div>
<p>The ChaCha20 stream cipher.</p>
<p>ChaCha20 is defined in RFC 7539.</p>
<p>The nonce size for <a class="reference internal" href="#c.psa_cipher_set_iv" title="psa_cipher_set_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_set_iv()</span></code></a> or <a class="reference internal" href="#c.psa_cipher_generate_iv" title="psa_cipher_generate_iv"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_cipher_generate_iv()</span></code></a> must be 12.</p>
<p>The initial block counter is always 0.</p>
</div>
<div class="section" id="PSA_ALG_CTR">
<span id="c.PSA_ALG_CTR"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CTR</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CTR  ((psa_algorithm_t)0x04c00001)</span>
</pre></div>
</div>
<p>The CTR stream cipher mode.</p>
<p>CTR is a stream cipher which is built from a block cipher. The underlying block cipher is determined by the key type. For example, to use AES-128-CTR, use this algorithm with a key of type <a class="reference internal" href="#c.PSA_KEY_TYPE_AES" title="PSA_KEY_TYPE_AES"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_AES</span></code></a> and a length of 128 bits (16 bytes).</p>
</div>
<div class="section" id="PSA_ALG_CFB">
<span id="c.PSA_ALG_CFB"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CFB</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CFB  ((psa_algorithm_t)0x04c00002)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_OFB">
<span id="c.PSA_ALG_OFB"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_OFB</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_OFB  ((psa_algorithm_t)0x04c00003)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_XTS">
<span id="c.PSA_ALG_XTS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_XTS</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_XTS  ((psa_algorithm_t)0x044000ff)</span>
</pre></div>
</div>
<p>The XTS cipher mode.</p>
<p>XTS is a cipher mode which is built from a block cipher. It requires at least one full block of input, but beyond this minimum the input does not need to be a whole number of blocks.</p>
</div>
<div class="section" id="PSA_ALG_CBC_NO_PADDING">
<span id="c.PSA_ALG_CBC_NO_PADDING"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CBC_NO_PADDING</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CBC_NO_PADDING  ((psa_algorithm_t)0x04600100)</span>
</pre></div>
</div>
<p>The CBC block cipher chaining mode, with no padding.</p>
<p>The underlying block cipher is determined by the key type.</p>
<p>This symmetric cipher mode can only be used with messages whose lengths are whole number of blocks for the chosen block cipher.</p>
</div>
<div class="section" id="PSA_ALG_CBC_PKCS7">
<span id="c.PSA_ALG_CBC_PKCS7"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CBC_PKCS7</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CBC_PKCS7  ((psa_algorithm_t)0x04600101)</span>
</pre></div>
</div>
<p>The CBC block cipher chaining mode with PKCS#7 padding.</p>
<p>The underlying block cipher is determined by the key type.</p>
<p>This is the padding method defined by PKCS#7 (RFC 2315) §10.3.</p>
</div>
<div class="section" id="PSA_ALG_AEAD_FROM_BLOCK_FLAG">
<span id="c.PSA_ALG_AEAD_FROM_BLOCK_FLAG"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_FROM_BLOCK_FLAG</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_AEAD_FROM_BLOCK_FLAG  ((psa_algorithm_t)0x00400000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER">
<span id="c.PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) \</span>
<span class="cp">    (((alg) &amp; (PSA_ALG_CATEGORY_MASK | PSA_ALG_AEAD_FROM_BLOCK_FLAG)) == (PSA_ALG_CATEGORY_AEAD | PSA_ALG_AEAD_FROM_BLOCK_FLAG))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is an AEAD algorithm which is an AEAD mode based on a block cipher, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is an AEAD mode on a block cipher.</p>
</div>
<div class="section" id="PSA_ALG_CCM">
<span id="c.PSA_ALG_CCM"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CCM</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CCM  ((psa_algorithm_t)0x06401001)</span>
</pre></div>
</div>
<p>The CCM authenticated encryption algorithm.</p>
</div>
<div class="section" id="PSA_ALG_GCM">
<span id="c.PSA_ALG_GCM"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_GCM</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_GCM  ((psa_algorithm_t)0x06401002)</span>
</pre></div>
</div>
<p>The GCM authenticated encryption algorithm.</p>
</div>
<div class="section" id="PSA_ALG_CHACHA20_POLY1305">
<span id="c.PSA_ALG_CHACHA20_POLY1305"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CHACHA20_POLY1305</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_CHACHA20_POLY1305  ((psa_algorithm_t)0x06001005)</span>
</pre></div>
</div>
<p>The Chacha20-Poly1305 AEAD algorithm.</p>
<p>The ChaCha20_Poly1305 construction is defined in RFC 7539.</p>
<p>Implementations must support 12-byte nonces, may support 8-byte nonces, and should reject other sizes.</p>
<p>Implementations must support 16-byte tags and should reject other sizes.</p>
</div>
<div class="section" id="PSA_ALG_AEAD_TAG_LENGTH_MASK">
<span id="c.PSA_ALG_AEAD_TAG_LENGTH_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_TAG_LENGTH_MASK</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_AEAD_TAG_LENGTH_MASK  ((psa_algorithm_t)0x00003f00)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_AEAD_TAG_LENGTH_OFFSET">
<span id="c.PSA_AEAD_TAG_LENGTH_OFFSET"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_TAG_LENGTH_OFFSET</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_TAG_LENGTH_OFFSET  8</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_AEAD_WITH_TAG_LENGTH">
<span id="c.PSA_ALG_AEAD_WITH_TAG_LENGTH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_WITH_TAG_LENGTH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_AEAD_WITH_TAG_LENGTH(aead_alg, tag_length) \</span>
<span class="cp">    (((aead_alg) &amp; ~PSA_ALG_AEAD_TAG_LENGTH_MASK) | ((tag_length) &lt;&lt; PSA_AEAD_TAG_LENGTH_OFFSET &amp; PSA_ALG_AEAD_TAG_LENGTH_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">aead_alg</span></code></dt>
<dd>An AEAD algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a> such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">tag_length</span></code></dt>
<dd>Desired length of the authentication tag in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding AEAD algorithm with the specified length.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported AEAD algorithm or if <code class="docutils literal notranslate"><span class="pre">tag_length</span></code> is not valid for the specified AEAD algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Macro to build a shortened AEAD algorithm.</p>
<p>A shortened AEAD algorithm is similar to the corresponding AEAD algorithm, but has an authentication tag that consists of fewer bytes. Depending on the algorithm, the tag length may affect the calculation of the ciphertext.</p>
</div>
<div class="section" id="PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH">
<span id="c.PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH(aead_alg) \</span>
<span class="cp">    ( PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE(aead_alg, PSA_ALG_CCM) PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE(aead_alg, PSA_ALG_GCM) PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE(aead_alg, PSA_ALG_CHACHA20_POLY1305) 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">aead_alg</span></code></dt>
<dd>An AEAD algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding AEAD algorithm with the default tag length for that algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Calculate the corresponding AEAD algorithm with the default tag length.</p>
</div>
<div class="section" id="PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE">
<span id="c.PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE(aead_alg, ref) \</span>
<span class="cp">    PSA_ALG_AEAD_WITH_TAG_LENGTH(aead_alg, 0) == PSA_ALG_AEAD_WITH_TAG_LENGTH(ref, 0) ? ref :</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">aead_alg</span></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"><span class="pre">ref</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_RSA_PKCS1V15_SIGN_BASE">
<span id="c.PSA_ALG_RSA_PKCS1V15_SIGN_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_PKCS1V15_SIGN_BASE  ((psa_algorithm_t)0x10020000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_RSA_PKCS1V15_SIGN">
<span id="c.PSA_ALG_RSA_PKCS1V15_SIGN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_PKCS1V15_SIGN(hash_alg) \</span>
<span class="cp">    (PSA_ALG_RSA_PKCS1V15_SIGN_BASE | ((hash_alg) &amp; PSA_ALG_HASH_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt>
<dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true). This includes <a class="reference internal" href="#c.PSA_ALG_ANY_HASH" title="PSA_ALG_ANY_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ANY_HASH</span></code></a> when specifying the algorithm in a usage policy.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding RSA PKCS#1 v1.5 signature algorithm.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>RSA PKCS#1 v1.5 signature with hashing.</p>
<p>This is the signature scheme defined by RFC 8017 (PKCS#1: RSA Cryptography Specifications) under the name RSASSA-PKCS1-v1_5.</p>
</div>
<div class="section" id="PSA_ALG_RSA_PKCS1V15_SIGN_RAW">
<span id="c.PSA_ALG_RSA_PKCS1V15_SIGN_RAW"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN_RAW</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_PKCS1V15_SIGN_RAW  PSA_ALG_RSA_PKCS1V15_SIGN_BASE</span>
</pre></div>
</div>
<p>Raw PKCS#1 v1.5 signature.</p>
<p>The input to this algorithm is the DigestInfo structure used by RFC 8017 (PKCS#1: RSA Cryptography Specifications), §9.2 steps 3–6.</p>
</div>
<div class="section" id="PSA_ALG_IS_RSA_PKCS1V15_SIGN">
<span id="c.PSA_ALG_IS_RSA_PKCS1V15_SIGN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RSA_PKCS1V15_SIGN</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) \</span>
<span class="cp">    (((alg) &amp; ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PKCS1V15_SIGN_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_RSA_PSS_BASE">
<span id="c.PSA_ALG_RSA_PSS_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PSS_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_PSS_BASE  ((psa_algorithm_t)0x10030000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_RSA_PSS">
<span id="c.PSA_ALG_RSA_PSS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PSS</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_PSS(hash_alg) \</span>
<span class="cp">    (PSA_ALG_RSA_PSS_BASE | ((hash_alg) &amp; PSA_ALG_HASH_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt>
<dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true). This includes <a class="reference internal" href="#c.PSA_ALG_ANY_HASH" title="PSA_ALG_ANY_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ANY_HASH</span></code></a> when specifying the algorithm in a usage policy.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding RSA PSS signature algorithm.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>RSA PSS signature with hashing.</p>
<p>This is the signature scheme defined by RFC 8017 (PKCS#1: RSA Cryptography Specifications) under the name RSASSA-PSS, with the message generation function MGF1, and with a salt length equal to the length of the hash. The specified hash algorithm is used to hash the input message, to create the salted hash, and for the mask generation.</p>
</div>
<div class="section" id="PSA_ALG_IS_RSA_PSS">
<span id="c.PSA_ALG_IS_RSA_PSS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RSA_PSS</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_RSA_PSS(alg) \</span>
<span class="cp">    (((alg) &amp; ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_PSS_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_ECDSA_BASE">
<span id="c.PSA_ALG_ECDSA_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_ECDSA_BASE  ((psa_algorithm_t)0x10060000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_ECDSA">
<span id="c.PSA_ALG_ECDSA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_ECDSA(hash_alg) \</span>
<span class="cp">    (PSA_ALG_ECDSA_BASE | ((hash_alg) &amp; PSA_ALG_HASH_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt>
<dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true). This includes <a class="reference internal" href="#c.PSA_ALG_ANY_HASH" title="PSA_ALG_ANY_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ANY_HASH</span></code></a> when specifying the algorithm in a usage policy.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding ECDSA signature algorithm.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>ECDSA signature with hashing.</p>
<p>This is the ECDSA signature scheme defined by ANSI X9.62, with a random per-message secret number (<em>k</em>).</p>
<p>The representation of the signature as a byte string consists of the concatentation of the signature values <em>r</em> and <em>s</em>. Each of <em>r</em> and <em>s</em> is encoded as an <em>N</em>-octet string, where <em>N</em> is the length of the base point of the curve in octets. Each value is represented in big-endian order (most significant octet first).</p>
</div>
<div class="section" id="PSA_ALG_ECDSA_ANY">
<span id="c.PSA_ALG_ECDSA_ANY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA_ANY</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_ECDSA_ANY  PSA_ALG_ECDSA_BASE</span>
</pre></div>
</div>
<p>ECDSA signature without hashing.</p>
<p>This is the same signature scheme as <a class="reference internal" href="#c.PSA_ALG_ECDSA" title="PSA_ALG_ECDSA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA()</span></code></a>, but without specifying a hash algorithm. This algorithm may only be used to sign or verify a sequence of bytes that should be an already-calculated hash. Note that the input is padded with zeros on the left or truncated on the left as required to fit the curve size.</p>
</div>
<div class="section" id="PSA_ALG_DETERMINISTIC_ECDSA_BASE">
<span id="c.PSA_ALG_DETERMINISTIC_ECDSA_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_DETERMINISTIC_ECDSA_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_DETERMINISTIC_ECDSA_BASE  ((psa_algorithm_t)0x10070000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_DETERMINISTIC_ECDSA">
<span id="c.PSA_ALG_DETERMINISTIC_ECDSA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_DETERMINISTIC_ECDSA</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_DETERMINISTIC_ECDSA(hash_alg) \</span>
<span class="cp">    (PSA_ALG_DETERMINISTIC_ECDSA_BASE | ((hash_alg) &amp; PSA_ALG_HASH_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt>
<dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true). This includes <a class="reference internal" href="#c.PSA_ALG_ANY_HASH" title="PSA_ALG_ANY_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ANY_HASH</span></code></a> when specifying the algorithm in a usage policy.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding deterministic ECDSA signature algorithm.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Deterministic ECDSA signature with hashing.</p>
<p>This is the deterministic ECDSA signature scheme defined by RFC 6979.</p>
<p>The representation of a signature is the same as with <a class="reference internal" href="#c.PSA_ALG_ECDSA" title="PSA_ALG_ECDSA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA()</span></code></a>.</p>
<p>Note that when this algorithm is used for verification, signatures made with randomized ECDSA (<a class="reference internal" href="#c.PSA_ALG_ECDSA" title="PSA_ALG_ECDSA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>)) with the same private key are accepted. In other words, <a class="reference internal" href="#c.PSA_ALG_DETERMINISTIC_ECDSA" title="PSA_ALG_DETERMINISTIC_ECDSA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_DETERMINISTIC_ECDSA</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) differs from <a class="reference internal" href="#c.PSA_ALG_ECDSA" title="PSA_ALG_ECDSA"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) only for signature, not for verification.</p>
</div>
<div class="section" id="PSA_ALG_IS_ECDSA">
<span id="c.PSA_ALG_IS_ECDSA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_ECDSA</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_ECDSA(alg) \</span>
<span class="cp">    (((alg) &amp; ~PSA_ALG_HASH_MASK &amp; ~PSA_ALG_DSA_DETERMINISTIC_FLAG) == PSA_ALG_ECDSA_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_ECDSA_IS_DETERMINISTIC">
<span id="c.PSA_ALG_ECDSA_IS_DETERMINISTIC"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA_IS_DETERMINISTIC</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_ECDSA_IS_DETERMINISTIC(alg) \</span>
<span class="cp">    (((alg) &amp; PSA_ALG_DSA_DETERMINISTIC_FLAG) != 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_IS_DETERMINISTIC_ECDSA">
<span id="c.PSA_ALG_IS_DETERMINISTIC_ECDSA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_DETERMINISTIC_ECDSA</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_DETERMINISTIC_ECDSA(alg) \</span>
<span class="cp">    (PSA_ALG_IS_ECDSA(alg) &amp;&amp; PSA_ALG_ECDSA_IS_DETERMINISTIC(alg))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_IS_RANDOMIZED_ECDSA">
<span id="c.PSA_ALG_IS_RANDOMIZED_ECDSA"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RANDOMIZED_ECDSA</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_RANDOMIZED_ECDSA(alg) \</span>
<span class="cp">    (PSA_ALG_IS_ECDSA(alg) &amp;&amp; !PSA_ALG_ECDSA_IS_DETERMINISTIC(alg))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_IS_HASH_AND_SIGN">
<span id="c.PSA_ALG_IS_HASH_AND_SIGN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH_AND_SIGN</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_HASH_AND_SIGN(alg) \</span>
<span class="cp">    (PSA_ALG_IS_RSA_PSS(alg) || PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) || PSA_ALG_IS_ECDSA(alg))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a hash-and-sign algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is a hash-and-sign algorithm.</p>
<p>Hash-and-sign algorithms are public-key signature algorithms structured in two parts: first the calculation of a hash in a way that does not depend on the key, then the calculation of a signature from the hash value and the key.</p>
</div>
<div class="section" id="PSA_ALG_SIGN_GET_HASH">
<span id="c.PSA_ALG_SIGN_GET_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SIGN_GET_HASH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_SIGN_GET_HASH(alg) \</span>
<span class="cp">    (PSA_ALG_IS_HASH_AND_SIGN(alg) ? ((alg) &amp; PSA_ALG_HASH_MASK) == 0 ? </span><span class="cm">/*&quot;raw&quot; algorithm*/</span><span class="cp"> 0 : ((alg) &amp; PSA_ALG_HASH_MASK) | PSA_ALG_CATEGORY_HASH : 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>A signature algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_SIGN" title="PSA_ALG_IS_SIGN"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_SIGN</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The underlying hash algorithm if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a hash-and-sign algorithm.</p>
<p>0 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a signature algorithm that does not follow the hash-and-sign structure.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a signature algorithm or if it is not supported by the implementation.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Get the hash used by a hash-and-sign signature algorithm.</p>
<p>A hash-and-sign algorithm is a signature algorithm which is composed of two phases: first a hashing phase which does not use the key and produces a hash of the input message, then a signing phase which only uses the hash and the key and not the message itself.</p>
</div>
<div class="section" id="PSA_ALG_RSA_PKCS1V15_CRYPT">
<span id="c.PSA_ALG_RSA_PKCS1V15_CRYPT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_CRYPT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_PKCS1V15_CRYPT  ((psa_algorithm_t)0x12020000)</span>
</pre></div>
</div>
<p>RSA PKCS#1 v1.5 encryption.</p>
</div>
<div class="section" id="PSA_ALG_RSA_OAEP_BASE">
<span id="c.PSA_ALG_RSA_OAEP_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_OAEP_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_OAEP_BASE  ((psa_algorithm_t)0x12030000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_RSA_OAEP">
<span id="c.PSA_ALG_RSA_OAEP"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_OAEP</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_OAEP(hash_alg) \</span>
<span class="cp">    (PSA_ALG_RSA_OAEP_BASE | ((hash_alg) &amp; PSA_ALG_HASH_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt>
<dd>The hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true) to use for MGF1.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding RSA OAEP signature algorithm.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>RSA OAEP encryption.</p>
<p>This is the encryption scheme defined by RFC 8017 (PKCS#1: RSA Cryptography Specifications) under the name RSAES-OAEP, with the message generation function MGF1.</p>
</div>
<div class="section" id="PSA_ALG_IS_RSA_OAEP">
<span id="c.PSA_ALG_IS_RSA_OAEP"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RSA_OAEP</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_RSA_OAEP(alg) \</span>
<span class="cp">    (((alg) &amp; ~PSA_ALG_HASH_MASK) == PSA_ALG_RSA_OAEP_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_RSA_OAEP_GET_HASH">
<span id="c.PSA_ALG_RSA_OAEP_GET_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_OAEP_GET_HASH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_RSA_OAEP_GET_HASH(alg) \</span>
<span class="cp">    (PSA_ALG_IS_RSA_OAEP(alg) ? ((alg) &amp; PSA_ALG_HASH_MASK) | PSA_ALG_CATEGORY_HASH : 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_HKDF_BASE">
<span id="c.PSA_ALG_HKDF_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HKDF_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_HKDF_BASE  ((psa_algorithm_t)0x20000100)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_HKDF">
<span id="c.PSA_ALG_HKDF"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HKDF</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_HKDF(hash_alg) \</span>
<span class="cp">    (PSA_ALG_HKDF_BASE | ((hash_alg) &amp; PSA_ALG_HASH_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt>
<dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding HKDF algorithm.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Macro to build an HKDF algorithm.</p>
<p>For example, <code class="docutils literal notranslate"><span class="pre">PSA_ALG_HKDF(PSA_ALG_SHA256)</span></code> is HKDF using HMAC-SHA-256.</p>
<p>This key derivation algorithm uses the following inputs:</p>
<ul class="simple">
<li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SALT" title="PSA_KEY_DERIVATION_INPUT_SALT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SALT</span></code></a> is the salt used in the “extract” step. It is optional; if omitted, the derivation uses an empty salt.</li>
<li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SECRET" title="PSA_KEY_DERIVATION_INPUT_SECRET"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SECRET</span></code></a> is the secret key used in the “extract” step.</li>
<li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_INFO" title="PSA_KEY_DERIVATION_INPUT_INFO"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_INFO</span></code></a> is the info string used in the “expand” step. You must pass <a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SALT" title="PSA_KEY_DERIVATION_INPUT_SALT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SALT</span></code></a> before <a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SECRET" title="PSA_KEY_DERIVATION_INPUT_SECRET"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SECRET</span></code></a>. You may pass <a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_INFO" title="PSA_KEY_DERIVATION_INPUT_INFO"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_INFO</span></code></a> at any time after steup and before starting to generate output.</li>
</ul>
</div>
<div class="section" id="PSA_ALG_IS_HKDF">
<span id="c.PSA_ALG_IS_HKDF"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HKDF</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_HKDF(alg) \</span>
<span class="cp">    (((alg) &amp; ~PSA_ALG_HASH_MASK) == PSA_ALG_HKDF_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is an HKDF algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported key derivation algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is an HKDF algorithm.</p>
<p>HKDF is a family of key derivation algorithms that are based on a hash function and the HMAC construction.</p>
</div>
<div class="section" id="PSA_ALG_HKDF_GET_HASH">
<span id="c.PSA_ALG_HKDF_GET_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HKDF_GET_HASH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_HKDF_GET_HASH(hkdf_alg) \</span>
<span class="cp">    (PSA_ALG_CATEGORY_HASH | ((hkdf_alg) &amp; PSA_ALG_HASH_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">hkdf_alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_TLS12_PRF_BASE">
<span id="c.PSA_ALG_TLS12_PRF_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PRF_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TLS12_PRF_BASE  ((psa_algorithm_t)0x20000200)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_TLS12_PRF">
<span id="c.PSA_ALG_TLS12_PRF"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PRF</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TLS12_PRF(hash_alg) \</span>
<span class="cp">    (PSA_ALG_TLS12_PRF_BASE | ((hash_alg) &amp; PSA_ALG_HASH_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt>
<dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding TLS-1.2 PRF algorithm.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Macro to build a TLS-1.2 PRF algorithm.</p>
<p>TLS 1.2 uses a custom pseudorandom function (PRF) for key schedule, specified in Section 5 of RFC 5246. It is based on HMAC and can be used with either SHA-256 or SHA-384.</p>
<p>This key derivation algorithm uses the following inputs:</p>
<ul class="simple">
<li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SECRET" title="PSA_KEY_DERIVATION_INPUT_SECRET"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SECRET</span></code></a> is the secret key.</li>
<li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_LABEL" title="PSA_KEY_DERIVATION_INPUT_LABEL"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_LABEL</span></code></a> is the label.</li>
<li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SEED" title="PSA_KEY_DERIVATION_INPUT_SEED"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SEED</span></code></a> is the seed.</li>
</ul>
<p>For the application to TLS-1.2 key expansion, the seed is the concatenation of ServerHello.Random + ClientHello.Random, and the label is “key expansion”.</p>
<p>For example, <code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PRF(PSA_ALG_SHA256)</span></code> represents the TLS 1.2 PRF using HMAC-SHA-256.</p>
</div>
<div class="section" id="PSA_ALG_IS_TLS12_PRF">
<span id="c.PSA_ALG_IS_TLS12_PRF"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_TLS12_PRF</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_TLS12_PRF(alg) \</span>
<span class="cp">    (((alg) &amp; ~PSA_ALG_HASH_MASK) == PSA_ALG_TLS12_PRF_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a TLS-1.2 PRF algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported key derivation algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is a TLS-1.2 PRF algorithm.</p>
</div>
<div class="section" id="PSA_ALG_TLS12_PRF_GET_HASH">
<span id="c.PSA_ALG_TLS12_PRF_GET_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PRF_GET_HASH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TLS12_PRF_GET_HASH(hkdf_alg) \</span>
<span class="cp">    (PSA_ALG_CATEGORY_HASH | ((hkdf_alg) &amp; PSA_ALG_HASH_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">hkdf_alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_TLS12_PSK_TO_MS_BASE">
<span id="c.PSA_ALG_TLS12_PSK_TO_MS_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TLS12_PSK_TO_MS_BASE  ((psa_algorithm_t)0x20000300)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_TLS12_PSK_TO_MS">
<span id="c.PSA_ALG_TLS12_PSK_TO_MS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TLS12_PSK_TO_MS(hash_alg) \</span>
<span class="cp">    (PSA_ALG_TLS12_PSK_TO_MS_BASE | ((hash_alg) &amp; PSA_ALG_HASH_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code></dt>
<dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding TLS-1.2 PSK to MS algorithm.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is not a supported hash algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Macro to build a TLS-1.2 PSK-to-MasterSecret algorithm.</p>
<p>In a pure-PSK handshake in TLS 1.2, the master secret is derived from the PreSharedKey (PSK) through the application of padding (RFC 4279, Section 2) and the TLS-1.2 PRF (RFC 5246, Section 5). The latter is based on HMAC and can be used with either SHA-256 or SHA-384.</p>
<p>This key derivation algorithm uses the following inputs:</p>
<ul class="simple">
<li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SECRET" title="PSA_KEY_DERIVATION_INPUT_SECRET"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SECRET</span></code></a> is the secret key.</li>
<li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_LABEL" title="PSA_KEY_DERIVATION_INPUT_LABEL"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_LABEL</span></code></a> is the label.</li>
<li><a class="reference internal" href="#c.PSA_KEY_DERIVATION_INPUT_SEED" title="PSA_KEY_DERIVATION_INPUT_SEED"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SEED</span></code></a> is the seed.</li>
</ul>
<p>For the application to TLS-1.2, the seed (which is forwarded to the TLS-1.2 PRF) is the concatenation of the ClientHello.Random + ServerHello.Random, and the label is “master secret” or “extended master secret”.</p>
<p>For example, <code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS(PSA_ALG_SHA256)</span></code> represents the TLS-1.2 PSK to MasterSecret derivation PRF using HMAC-SHA-256.</p>
</div>
<div class="section" id="PSA_ALG_IS_TLS12_PSK_TO_MS">
<span id="c.PSA_ALG_IS_TLS12_PSK_TO_MS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_TLS12_PSK_TO_MS</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_TLS12_PSK_TO_MS(alg) \</span>
<span class="cp">    (((alg) &amp; ~PSA_ALG_HASH_MASK) == PSA_ALG_TLS12_PSK_TO_MS_BASE)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a TLS-1.2 PSK to MS algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported key derivation algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is a TLS-1.2 PSK to MS algorithm.</p>
</div>
<div class="section" id="PSA_ALG_TLS12_PSK_TO_MS_GET_HASH">
<span id="c.PSA_ALG_TLS12_PSK_TO_MS_GET_HASH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS_GET_HASH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TLS12_PSK_TO_MS_GET_HASH(hkdf_alg) \</span>
<span class="cp">    (PSA_ALG_CATEGORY_HASH | ((hkdf_alg) &amp; PSA_ALG_HASH_MASK))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">hkdf_alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_KEY_DERIVATION_MASK">
<span id="c.PSA_ALG_KEY_DERIVATION_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_DERIVATION_MASK</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_KEY_DERIVATION_MASK  ((psa_algorithm_t)0x0803ffff)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_KEY_AGREEMENT_MASK">
<span id="c.PSA_ALG_KEY_AGREEMENT_MASK"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT_MASK</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_KEY_AGREEMENT_MASK  ((psa_algorithm_t)0x10fc0000)</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ALG_KEY_AGREEMENT">
<span id="c.PSA_ALG_KEY_AGREEMENT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_KEY_AGREEMENT(ka_alg, kdf_alg)  ((ka_alg) | (kdf_alg))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">ka_alg</span></code></dt>
<dd>A key agreement algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_KEY_AGREEMENT" title="PSA_ALG_IS_KEY_AGREEMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_AGREEMENT</span></code></a>(<code class="docutils literal notranslate"><span class="pre">ka_alg</span></code>) is true).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">kdf_alg</span></code></dt>
<dd>A key derivation algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_KEY_DERIVATION" title="PSA_ALG_IS_KEY_DERIVATION"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_DERIVATION</span></code></a>(<code class="docutils literal notranslate"><span class="pre">kdf_alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The corresponding key agreement and derivation algorithm.</p>
<p>Unspecified if <code class="docutils literal notranslate"><span class="pre">ka_alg</span></code> is not a supported key agreement algorithm or <code class="docutils literal notranslate"><span class="pre">kdf_alg</span></code> is not a supported key derivation algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Macro to build a combined algorithm that chains a key agreement with a key derivation.</p>
</div>
<div class="section" id="PSA_ALG_KEY_AGREEMENT_GET_KDF">
<span id="c.PSA_ALG_KEY_AGREEMENT_GET_KDF"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT_GET_KDF</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_KEY_AGREEMENT_GET_KDF(alg) \</span>
<span class="cp">    (((alg) &amp; PSA_ALG_KEY_DERIVATION_MASK) | PSA_ALG_CATEGORY_KEY_DERIVATION)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_KEY_AGREEMENT_GET_BASE">
<span id="c.PSA_ALG_KEY_AGREEMENT_GET_BASE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT_GET_BASE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_KEY_AGREEMENT_GET_BASE(alg) \</span>
<span class="cp">    (((alg) &amp; PSA_ALG_KEY_AGREEMENT_MASK) | PSA_ALG_CATEGORY_KEY_AGREEMENT)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_IS_RAW_KEY_AGREEMENT">
<span id="c.PSA_ALG_IS_RAW_KEY_AGREEMENT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RAW_KEY_AGREEMENT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_RAW_KEY_AGREEMENT(alg) \</span>
<span class="cp">    (PSA_ALG_IS_KEY_AGREEMENT(alg) &amp;&amp; PSA_ALG_KEY_AGREEMENT_GET_KDF(alg) == PSA_ALG_CATEGORY_KEY_DERIVATION)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a raw key agreement algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is a raw key agreement algorithm.</p>
<p>A raw key agreement algorithm is one that does not specify a key derivation function. Usually, raw key agreement algorithms are constructed directly with a <code class="docutils literal notranslate"><span class="pre">PSA_ALG_xxx</span></code> macro while non-raw key agreement algorithms are constructed with <a class="reference internal" href="#c.PSA_ALG_KEY_AGREEMENT" title="PSA_ALG_KEY_AGREEMENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT()</span></code></a>.</p>
</div>
<div class="section" id="PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT">
<span id="c.PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT(alg) \</span>
<span class="cp">    ((PSA_ALG_IS_KEY_DERIVATION(alg) || PSA_ALG_IS_KEY_AGREEMENT(alg)))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ALG_FFDH">
<span id="c.PSA_ALG_FFDH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_FFDH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_FFDH  ((psa_algorithm_t)0x30100000)</span>
</pre></div>
</div>
<p>The finite-field Diffie-Hellman (DH) key agreement algorithm.</p>
<p>The shared secret produced by key agreement is <code class="docutils literal notranslate"><span class="pre">g^{ab}</span></code> in big-endian format. It is <code class="docutils literal notranslate"><span class="pre">ceiling(m</span> <span class="pre">/</span> <span class="pre">8)</span></code> bytes long where <code class="docutils literal notranslate"><span class="pre">m</span></code> is the size of the prime <code class="docutils literal notranslate"><span class="pre">p</span></code> in bits.</p>
</div>
<div class="section" id="PSA_ALG_IS_FFDH">
<span id="c.PSA_ALG_IS_FFDH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_FFDH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_FFDH(alg) \</span>
<span class="cp">    (PSA_ALG_KEY_AGREEMENT_GET_BASE(alg) == PSA_ALG_FFDH)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a finite field Diffie-Hellman algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported key agreement algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is a finite field Diffie-Hellman algorithm.</p>
<p>This includes the raw finite field Diffie-Hellman algorithm as well as finite-field Diffie-Hellman followed by any supporter key derivation algorithm.</p>
</div>
<div class="section" id="PSA_ALG_ECDH">
<span id="c.PSA_ALG_ECDH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_ECDH  ((psa_algorithm_t)0x30200000)</span>
</pre></div>
</div>
<p>The elliptic curve Diffie-Hellman (ECDH) key agreement algorithm.</p>
<p>The shared secret produced by key agreement is the x-coordinate of the shared secret point. It is always <code class="docutils literal notranslate"><span class="pre">ceiling(m</span> <span class="pre">/</span> <span class="pre">8)</span></code> bytes long where <code class="docutils literal notranslate"><span class="pre">m</span></code> is the bit size associated with the curve, i.e. the bit size of the order of the curve’s coordinate field. When <code class="docutils literal notranslate"><span class="pre">m</span></code> is not a multiple of 8, the byte containing the most significant bit of the shared secret is padded with zero bits. The byte order is either little-endian or big-endian depending on the curve type.</p>
<ul class="simple">
<li>For Montgomery curves (curve types <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVEXXX</span></code>), the shared secret is the x-coordinate of <code class="docutils literal notranslate"><span class="pre">d_A</span> <span class="pre">Q_B</span> <span class="pre">=</span> <span class="pre">d_B</span> <span class="pre">Q_A</span></code> in little-endian byte order. The bit size is 448 for Curve448 and 255 for Curve25519.</li>
<li>For Weierstrass curves over prime fields (curve types <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECPXXX</span></code> and <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_PXXX</span></code>), the shared secret is the x-coordinate of <code class="docutils literal notranslate"><span class="pre">d_A</span> <span class="pre">Q_B</span> <span class="pre">=</span> <span class="pre">d_B</span> <span class="pre">Q_A</span></code> in big-endian byte order. The bit size is <code class="docutils literal notranslate"><span class="pre">m</span> <span class="pre">=</span> <span class="pre">ceiling(log_2(p))</span></code> for the field <code class="docutils literal notranslate"><span class="pre">F_p</span></code>.</li>
<li>For Weierstrass curves over binary fields (curve types <code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECTXXX</span></code>), the shared secret is the x-coordinate of <code class="docutils literal notranslate"><span class="pre">d_A</span> <span class="pre">Q_B</span> <span class="pre">=</span> <span class="pre">d_B</span> <span class="pre">Q_A</span></code> in big-endian byte order. The bit size is <code class="docutils literal notranslate"><span class="pre">m</span></code> for the field <code class="docutils literal notranslate"><span class="pre">F_{2^m}</span></code>.</li>
</ul>
</div>
<div class="section" id="PSA_ALG_IS_ECDH">
<span id="c.PSA_ALG_IS_ECDH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_ECDH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_ECDH(alg) \</span>
<span class="cp">    (PSA_ALG_KEY_AGREEMENT_GET_BASE(alg) == PSA_ALG_ECDH)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is an elliptic curve Diffie-Hellman algorithm, 0 otherwise. This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported key agreement algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm is an elliptic curve Diffie-Hellman algorithm.</p>
<p>This includes the raw elliptic curve Diffie-Hellman algorithm as well as elliptic curve Diffie-Hellman followed by any supporter key derivation algorithm.</p>
</div>
<div class="section" id="PSA_ALG_IS_WILDCARD">
<span id="c.PSA_ALG_IS_WILDCARD"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_WILDCARD</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_IS_WILDCARD(alg) \</span>
<span class="cp">    (PSA_ALG_IS_HASH_AND_SIGN(alg) ? PSA_ALG_SIGN_GET_HASH(alg) == PSA_ALG_ANY_HASH : (alg) == PSA_ALG_ANY_HASH)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An algorithm identifier (value of type <a class="reference internal" href="#c.psa_algorithm_t" title="psa_algorithm_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a wildcard algorithm encoding.</p>
<p>0 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is a non-wildcard algorithm encoding (suitable for an operation).</p>
<p>This macro may return either 0 or 1 if <code class="docutils literal notranslate"><span class="pre">alg</span></code> is not a supported algorithm identifier.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Whether the specified algorithm encoding is a wildcard.</p>
<p>Wildcard values may only be used to set the usage algorithm field in a policy, not to perform an operation.</p>
</div>
</div>
<div class="section" id="key-lifetimes">
<h1>Key lifetimes</h1>
<div class="section" id="psa_key_lifetime_t">
<span id="c.psa_key_lifetime_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_lifetime_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint32_t</span> <span class="n">psa_key_lifetime_t</span><span class="p">;</span>
</pre></div>
</div>
<p>Encoding of key lifetimes.</p>
<p>The lifetime of a key indicates where it is stored and what system actions may create and destroy it.</p>
<p>Keys with the lifetime <a class="reference internal" href="#c.PSA_KEY_LIFETIME_VOLATILE" title="PSA_KEY_LIFETIME_VOLATILE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code></a> are automatically destroyed when the application terminates or on a power reset.</p>
<p>Keys with a lifetime other than <a class="reference internal" href="#c.PSA_KEY_LIFETIME_VOLATILE" title="PSA_KEY_LIFETIME_VOLATILE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code></a> are said to be <em>persistent</em>. Persistent keys are preserved if the application or the system restarts. Persistent keys have a key identifier of type <a class="reference internal" href="#c.psa_key_id_t" title="psa_key_id_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_key_id_t</span></code></a>. The application can call <a class="reference internal" href="#c.psa_open_key" title="psa_open_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_open_key()</span></code></a> to open a persistent key that it created previously.</p>
</div>
<div class="section" id="psa_key_id_t">
<span id="c.psa_key_id_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_id_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint32_t</span> <span class="n">psa_key_id_t</span><span class="p">;</span>
</pre></div>
</div>
<p>Encoding of identifiers of persistent keys.</p>
<ul class="simple">
<li>Applications may freely choose key identifiers in the range <a class="reference internal" href="#c.PSA_KEY_ID_USER_MIN" title="PSA_KEY_ID_USER_MIN"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_ID_USER_MIN</span></code></a> to <a class="reference internal" href="#c.PSA_KEY_ID_USER_MAX" title="PSA_KEY_ID_USER_MAX"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_ID_USER_MAX</span></code></a>.</li>
<li>Implementations may define additional key identifiers in the range <a class="reference internal" href="#c.PSA_KEY_ID_VENDOR_MIN" title="PSA_KEY_ID_VENDOR_MIN"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MIN</span></code></a> to <a class="reference internal" href="#c.PSA_KEY_ID_VENDOR_MAX" title="PSA_KEY_ID_VENDOR_MAX"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MAX</span></code></a>.</li>
<li>0 is reserved as an invalid key identifier.</li>
<li>Key identifiers outside these ranges are reserved for future use.</li>
</ul>
</div>
<div class="section" id="PSA_KEY_LIFETIME_VOLATILE">
<span id="c.PSA_KEY_LIFETIME_VOLATILE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_LIFETIME_VOLATILE  ((psa_key_lifetime_t)0x00000000)</span>
</pre></div>
</div>
<p>A volatile key only exists as long as the handle to it is not closed.</p>
<p>The key material is guaranteed to be erased on a power reset.</p>
</div>
<div class="section" id="PSA_KEY_LIFETIME_PERSISTENT">
<span id="c.PSA_KEY_LIFETIME_PERSISTENT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_PERSISTENT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_LIFETIME_PERSISTENT  ((psa_key_lifetime_t)0x00000001)</span>
</pre></div>
</div>
<p>The default storage area for persistent keys.</p>
<p>A persistent key remains in storage until it is explicitly destroyed or until the corresponding storage area is wiped. This specification does not define any mechanism to wipe a storage area, but implementations may provide their own mechanism (for example to perform a factory reset, to prepare for device refurbishment, or to uninstall an application).</p>
<p>This lifetime value is the default storage area for the calling application. Implementations may offer other storage areas designated by other lifetime values as implementation-specific extensions.</p>
</div>
<div class="section" id="PSA_KEY_ID_USER_MIN">
<span id="c.PSA_KEY_ID_USER_MIN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_USER_MIN</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_ID_USER_MIN  ((psa_key_id_t)0x00000001)</span>
</pre></div>
</div>
<p>The minimum value for a key identifier chosen by the application.</p>
</div>
<div class="section" id="PSA_KEY_ID_USER_MAX">
<span id="c.PSA_KEY_ID_USER_MAX"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_USER_MAX</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_ID_USER_MAX  ((psa_key_id_t)0x3fffffff)</span>
</pre></div>
</div>
<p>The maximum value for a key identifier chosen by the application.</p>
</div>
<div class="section" id="PSA_KEY_ID_VENDOR_MIN">
<span id="c.PSA_KEY_ID_VENDOR_MIN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MIN</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_ID_VENDOR_MIN  ((psa_key_id_t)0x40000000)</span>
</pre></div>
</div>
<p>The minimum value for a key identifier chosen by the implementation.</p>
</div>
<div class="section" id="PSA_KEY_ID_VENDOR_MAX">
<span id="c.PSA_KEY_ID_VENDOR_MAX"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MAX</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_ID_VENDOR_MAX  ((psa_key_id_t)0x7fffffff)</span>
</pre></div>
</div>
<p>The maximum value for a key identifier chosen by the implementation.</p>
</div>
</div>
<div class="section" id="key-policies">
<h1>Key policies</h1>
<div class="section" id="psa_key_usage_t">
<span id="c.psa_key_usage_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_usage_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint32_t</span> <span class="n">psa_key_usage_t</span><span class="p">;</span>
</pre></div>
</div>
<p>Encoding of permitted usage on a key.</p>
</div>
<div class="section" id="PSA_KEY_USAGE_EXPORT">
<span id="c.PSA_KEY_USAGE_EXPORT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_EXPORT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_USAGE_EXPORT  ((psa_key_usage_t)0x00000001)</span>
</pre></div>
</div>
<p>Whether the key may be exported.</p>
<p>A public key or the public part of a key pair may always be exported regardless of the value of this permission flag.</p>
<p>If a key does not have export permission, implementations shall not allow the key to be exported in plain form from the cryptoprocessor, whether through <a class="reference internal" href="#c.psa_export_key" title="psa_export_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_key()</span></code></a> or through a proprietary interface. The key may however be exportable in a wrapped form, i.e. in a form where it is encrypted by another key.</p>
</div>
<div class="section" id="PSA_KEY_USAGE_COPY">
<span id="c.PSA_KEY_USAGE_COPY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_COPY</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_USAGE_COPY  ((psa_key_usage_t)0x00000002)</span>
</pre></div>
</div>
<p>Whether the key may be copied.</p>
<p>This flag allows the use of <a class="reference internal" href="#c.psa_copy_key" title="psa_copy_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_copy_key()</span></code></a> to make a copy of the key with the same policy or a more restrictive policy.</p>
<p>For lifetimes for which the key is located in a secure element which enforce the non-exportability of keys, copying a key outside the secure element also requires the usage flag <a class="reference internal" href="#c.PSA_KEY_USAGE_EXPORT" title="PSA_KEY_USAGE_EXPORT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_EXPORT</span></code></a>. Copying the key inside the secure element is permitted with just <a class="reference internal" href="#c.PSA_KEY_USAGE_COPY" title="PSA_KEY_USAGE_COPY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_COPY</span></code></a> if the secure element supports it. For keys with the lifetime <a class="reference internal" href="#c.PSA_KEY_LIFETIME_VOLATILE" title="PSA_KEY_LIFETIME_VOLATILE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code></a> or <a class="reference internal" href="#c.PSA_KEY_LIFETIME_PERSISTENT" title="PSA_KEY_LIFETIME_PERSISTENT"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_PERSISTENT</span></code></a>, the usage flag <a class="reference internal" href="#c.PSA_KEY_USAGE_COPY" title="PSA_KEY_USAGE_COPY"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_COPY</span></code></a> is sufficient to permit the copy.</p>
</div>
<div class="section" id="PSA_KEY_USAGE_ENCRYPT">
<span id="c.PSA_KEY_USAGE_ENCRYPT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_ENCRYPT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_USAGE_ENCRYPT  ((psa_key_usage_t)0x00000100)</span>
</pre></div>
</div>
<p>Whether the key may be used to encrypt a message.</p>
<p>This flag allows the key to be used for a symmetric encryption operation, for an AEAD encryption-and-authentication operation, or for an asymmetric encryption operation, if otherwise permitted by the key’s type and policy.</p>
<p>For a key pair, this concerns the public key.</p>
</div>
<div class="section" id="PSA_KEY_USAGE_DECRYPT">
<span id="c.PSA_KEY_USAGE_DECRYPT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_DECRYPT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_USAGE_DECRYPT  ((psa_key_usage_t)0x00000200)</span>
</pre></div>
</div>
<p>Whether the key may be used to decrypt a message.</p>
<p>This flag allows the key to be used for a symmetric decryption operation, for an AEAD decryption-and-verification operation, or for an asymmetric decryption operation, if otherwise permitted by the key’s type and policy.</p>
<p>For a key pair, this concerns the private key.</p>
</div>
<div class="section" id="PSA_KEY_USAGE_SIGN">
<span id="c.PSA_KEY_USAGE_SIGN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_SIGN</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_USAGE_SIGN  ((psa_key_usage_t)0x00000400)</span>
</pre></div>
</div>
<p>Whether the key may be used to sign a message.</p>
<p>This flag allows the key to be used for a MAC calculation operation or for an asymmetric signature operation, if otherwise permitted by the key’s type and policy.</p>
<p>For a key pair, this concerns the private key.</p>
</div>
<div class="section" id="PSA_KEY_USAGE_VERIFY">
<span id="c.PSA_KEY_USAGE_VERIFY"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_VERIFY</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_USAGE_VERIFY  ((psa_key_usage_t)0x00000800)</span>
</pre></div>
</div>
<p>Whether the key may be used to verify a message signature.</p>
<p>This flag allows the key to be used for a MAC verification operation or for an asymmetric signature verification operation, if otherwise permitted by by the key’s type and policy.</p>
<p>For a key pair, this concerns the public key.</p>
</div>
<div class="section" id="PSA_KEY_USAGE_DERIVE">
<span id="c.PSA_KEY_USAGE_DERIVE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_DERIVE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_USAGE_DERIVE  ((psa_key_usage_t)0x00001000)</span>
</pre></div>
</div>
<p>Whether the key may be used to derive other keys.</p>
</div>
</div>
<div class="section" id="key-derivation">
<h1>Key derivation</h1>
<div class="section" id="psa_key_derivation_step_t">
<span id="c.psa_key_derivation_step_t"></span><h2><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_step_t</span></code> (type)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="k">typedef</span> <span class="kt">uint16_t</span> <span class="n">psa_key_derivation_step_t</span><span class="p">;</span>
</pre></div>
</div>
<p>Encoding of the step of a key derivation.</p>
</div>
<div class="section" id="PSA_KEY_DERIVATION_INPUT_SECRET">
<span id="c.PSA_KEY_DERIVATION_INPUT_SECRET"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SECRET</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_DERIVATION_INPUT_SECRET  ((psa_key_derivation_step_t)0x0101)</span>
</pre></div>
</div>
<p>A secret input for key derivation.</p>
<p>This must be a key of type <a class="reference internal" href="#c.PSA_KEY_TYPE_DERIVE" title="PSA_KEY_TYPE_DERIVE"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DERIVE</span></code></a>.</p>
</div>
<div class="section" id="PSA_KEY_DERIVATION_INPUT_LABEL">
<span id="c.PSA_KEY_DERIVATION_INPUT_LABEL"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_LABEL</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_DERIVATION_INPUT_LABEL  ((psa_key_derivation_step_t)0x0201)</span>
</pre></div>
</div>
<p>A label for key derivation.</p>
<p>This must be a direct input.</p>
</div>
<div class="section" id="PSA_KEY_DERIVATION_INPUT_SALT">
<span id="c.PSA_KEY_DERIVATION_INPUT_SALT"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SALT</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_DERIVATION_INPUT_SALT  ((psa_key_derivation_step_t)0x0202)</span>
</pre></div>
</div>
<p>A salt for key derivation.</p>
<p>This must be a direct input.</p>
</div>
<div class="section" id="PSA_KEY_DERIVATION_INPUT_INFO">
<span id="c.PSA_KEY_DERIVATION_INPUT_INFO"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_INFO</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_DERIVATION_INPUT_INFO  ((psa_key_derivation_step_t)0x0203)</span>
</pre></div>
</div>
<p>An information string for key derivation.</p>
<p>This must be a direct input.</p>
</div>
<div class="section" id="PSA_KEY_DERIVATION_INPUT_SEED">
<span id="c.PSA_KEY_DERIVATION_INPUT_SEED"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SEED</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_DERIVATION_INPUT_SEED  ((psa_key_derivation_step_t)0x0204)</span>
</pre></div>
</div>
<p>A seed for key derivation.</p>
<p>This must be a direct input.</p>
</div>
</div>
<div class="section" id="other-definitions">
<h1>Other definitions</h1>
<div class="section" id="PSA_BITS_TO_BYTES">
<span id="c.PSA_BITS_TO_BYTES"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_BITS_TO_BYTES</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_BITS_TO_BYTES(bits)  (((bits) + 7) / 8)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">bits</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_BYTES_TO_BITS">
<span id="c.PSA_BYTES_TO_BITS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_BYTES_TO_BITS</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_BYTES_TO_BITS(bytes)  ((bytes) * 8)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">bytes</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ROUND_UP_TO_MULTIPLE">
<span id="c.PSA_ROUND_UP_TO_MULTIPLE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ROUND_UP_TO_MULTIPLE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ROUND_UP_TO_MULTIPLE(block_size, length) \</span>
<span class="cp">    (((length) + (block_size) - 1) / (block_size) * (block_size))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">block_size</span></code></dt>
<dd></dd>
<dt> <code class="docutils literal notranslate"><span class="pre">length</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_HASH_SIZE">
<span id="c.PSA_HASH_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_HASH_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_HASH_SIZE(alg) \</span>
<span class="cp">    ( PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD2 ? 16 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD4 ? 16 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_MD5 ? 16 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_RIPEMD160 ? 20 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_1 ? 20 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_224 ? 28 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_256 ? 32 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_384 ? 48 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512 ? 64 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_224 ? 28 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA_512_256 ? 32 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_224 ? 28 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_256 ? 32 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_384 ? 48 : PSA_ALG_HMAC_GET_HASH(alg) == PSA_ALG_SHA3_512 ? 64 : 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>A hash algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_HASH" title="PSA_ALG_IS_HASH"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true), or an HMAC algorithm (<a class="reference internal" href="#c.PSA_ALG_HMAC" title="PSA_ALG_HMAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_HMAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">hash_alg</span></code>) where <code class="docutils literal notranslate"><span class="pre">hash_alg</span></code> is a hash algorithm).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The hash size for the specified hash algorithm. If the hash algorithm is not recognized, return 0. An implementation may return either 0 or the correct size for a hash algorithm that it recognizes, but does not support.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>The size of the output of <a class="reference internal" href="#c.psa_hash_finish" title="psa_hash_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_finish()</span></code></a>, in bytes.</p>
<p>This is also the hash size that <a class="reference internal" href="#c.psa_hash_verify" title="psa_hash_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_hash_verify()</span></code></a> expects.</p>
</div>
<div class="section" id="PSA_HASH_MAX_SIZE">
<span id="c.PSA_HASH_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_HASH_MAX_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_HASH_MAX_SIZE  64</span>
</pre></div>
</div>
<p>Maximum size of a hash.</p>
<p>This macro must expand to a compile-time constant integer. This value should be the maximum size of a hash supported by the implementation, in bytes, and must be no smaller than this maximum.</p>
</div>
<div class="section" id="PSA_HMAC_MAX_HASH_BLOCK_SIZE">
<span id="c.PSA_HMAC_MAX_HASH_BLOCK_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_HMAC_MAX_HASH_BLOCK_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_HMAC_MAX_HASH_BLOCK_SIZE  128</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_MAC_MAX_SIZE">
<span id="c.PSA_MAC_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_MAC_MAX_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_MAC_MAX_SIZE  PSA_HASH_MAX_SIZE</span>
</pre></div>
</div>
<p>Maximum size of a MAC.</p>
<p>This macro must expand to a compile-time constant integer. This value should be the maximum size of a MAC supported by the implementation, in bytes, and must be no smaller than this maximum.</p>
</div>
<div class="section" id="PSA_AEAD_TAG_LENGTH">
<span id="c.PSA_AEAD_TAG_LENGTH"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_TAG_LENGTH</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_TAG_LENGTH(alg) \</span>
<span class="cp">    (PSA_ALG_IS_AEAD(alg) ? (((alg) &amp; PSA_ALG_AEAD_TAG_LENGTH_MASK) &gt;&gt; PSA_AEAD_TAG_LENGTH_OFFSET) : 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An AEAD algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The tag size for the specified algorithm. If the AEAD algorithm does not have an identified tag that can be distinguished from the rest of the ciphertext, return 0. If the AEAD algorithm is not recognized, return 0. An implementation may return either 0 or a correct size for an AEAD algorithm that it recognizes, but does not support.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>The tag size for an AEAD algorithm, in bytes.</p>
</div>
<div class="section" id="PSA_VENDOR_RSA_MAX_KEY_BITS">
<span id="c.PSA_VENDOR_RSA_MAX_KEY_BITS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_VENDOR_RSA_MAX_KEY_BITS</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_VENDOR_RSA_MAX_KEY_BITS  4096</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_VENDOR_ECC_MAX_CURVE_BITS">
<span id="c.PSA_VENDOR_ECC_MAX_CURVE_BITS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_VENDOR_ECC_MAX_CURVE_BITS</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_VENDOR_ECC_MAX_CURVE_BITS  521</span>
</pre></div>
</div>
</div>
<div class="section" id="PSA_ECC_CURVE_BITS">
<span id="c.PSA_ECC_CURVE_BITS"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BITS</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECC_CURVE_BITS(curve)  </span><span class="cm">/*...*/</span><span class="cp"></span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">curve</span></code></dt>
<dd>An elliptic curve (value of type <a class="reference internal" href="#c.psa_ecc_curve_t" title="psa_ecc_curve_t"><code class="xref any c c-type docutils literal notranslate"><span class="pre">psa_ecc_curve_t</span></code></a>).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The size associated with <code class="docutils literal notranslate"><span class="pre">curve</span></code>, in bits. This may be 0 if the implementation does not support the specified curve.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Bit size associated with an elliptic curve.</p>
</div>
<div class="section" id="PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN">
<span id="c.PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN  128</span>
</pre></div>
</div>
<p>This macro returns the maximum length of the PSK supported by the TLS-1.2 PSK-to-MS key derivation.</p>
<p>Quoting RFC 4279, Sect 5.3: TLS implementations supporting these ciphersuites MUST support arbitrary PSK identities up to 128 octets in length, and arbitrary PSKs up to 64 octets in length. Supporting longer identities and keys is RECOMMENDED.</p>
<p>Therefore, no implementation should define a value smaller than 64 for <a class="reference internal" href="#c.PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN" title="PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN</span></code></a>.</p>
</div>
<div class="section" id="PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE">
<span id="c.PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE \</span>
<span class="cp">    PSA_BITS_TO_BYTES( PSA_VENDOR_RSA_MAX_KEY_BITS &gt; PSA_VENDOR_ECC_MAX_CURVE_BITS ? PSA_VENDOR_RSA_MAX_KEY_BITS : PSA_VENDOR_ECC_MAX_CURVE_BITS )</span>
</pre></div>
</div>
<p>Maximum size of an asymmetric signature.</p>
<p>This macro must expand to a compile-time constant integer. This value should be the maximum size of a MAC supported by the implementation, in bytes, and must be no smaller than this maximum.</p>
</div>
<div class="section" id="PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE">
<span id="c.PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE  16</span>
</pre></div>
</div>
<p>The maximum size of a block cipher supported by the implementation.</p>
</div>
<div class="section" id="PSA_MAC_FINAL_SIZE">
<span id="c.PSA_MAC_FINAL_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_MAC_FINAL_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_MAC_FINAL_SIZE(key_type, key_bits, alg) \</span>
<span class="cp">    ((alg) &amp; PSA_ALG_MAC_TRUNCATION_MASK ? PSA_MAC_TRUNCATED_LENGTH(alg) : PSA_ALG_IS_HMAC(alg) ? PSA_HASH_SIZE(PSA_ALG_HMAC_GET_HASH(alg)) : PSA_ALG_IS_BLOCK_CIPHER_MAC(alg) ? PSA_BLOCK_CIPHER_BLOCK_SIZE(key_type) : ((void)(key_type), (void)(key_bits), 0))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">key_type</span></code></dt>
<dd>The type of the MAC key.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt>
<dd>The size of the MAC key in bits.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>A MAC algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_MAC" title="PSA_ALG_IS_MAC"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The MAC size for the specified algorithm with the specified key parameters.</p>
<p>0 if the MAC algorithm is not recognized.</p>
<p>Either 0 or the correct size for a MAC algorithm that the implementation recognizes, but does not support.</p>
<p>Unspecified if the key parameters are not consistent with the algorithm.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>The size of the output of <a class="reference internal" href="#c.psa_mac_sign_finish" title="psa_mac_sign_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_sign_finish()</span></code></a>, in bytes.</p>
<p>This is also the MAC size that <a class="reference internal" href="#c.psa_mac_verify_finish" title="psa_mac_verify_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_mac_verify_finish()</span></code></a> expects.</p>
</div>
<div class="section" id="PSA_AEAD_ENCRYPT_OUTPUT_SIZE">
<span id="c.PSA_AEAD_ENCRYPT_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_ENCRYPT_OUTPUT_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_ENCRYPT_OUTPUT_SIZE(alg, plaintext_length) \</span>
<span class="cp">    (PSA_AEAD_TAG_LENGTH(alg) != 0 ? (plaintext_length) + PSA_AEAD_TAG_LENGTH(alg) : 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An AEAD algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">plaintext_length</span></code></dt>
<dd>Size of the plaintext in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The AEAD ciphertext size for the specified algorithm. If the AEAD algorithm is not recognized, return 0. An implementation may return either 0 or a correct size for an AEAD algorithm that it recognizes, but does not support.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>The maximum size of the output of <a class="reference internal" href="#c.psa_aead_encrypt" title="psa_aead_encrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt()</span></code></a>, in bytes.</p>
<p>If the size of the ciphertext buffer is at least this large, it is guaranteed that <a class="reference internal" href="#c.psa_aead_encrypt" title="psa_aead_encrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_encrypt()</span></code></a> will not fail due to an insufficient buffer size. Depending on the algorithm, the actual size of the ciphertext may be smaller.</p>
</div>
<div class="section" id="PSA_AEAD_DECRYPT_OUTPUT_SIZE">
<span id="c.PSA_AEAD_DECRYPT_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_DECRYPT_OUTPUT_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_DECRYPT_OUTPUT_SIZE(alg, ciphertext_length) \</span>
<span class="cp">    (PSA_AEAD_TAG_LENGTH(alg) != 0 ? (ciphertext_length) - PSA_AEAD_TAG_LENGTH(alg) : 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An AEAD algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">ciphertext_length</span></code></dt>
<dd>Size of the plaintext in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>The AEAD ciphertext size for the specified algorithm. If the AEAD algorithm is not recognized, return 0. An implementation may return either 0 or a correct size for an AEAD algorithm that it recognizes, but does not support.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>The maximum size of the output of <a class="reference internal" href="#c.psa_aead_decrypt" title="psa_aead_decrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt()</span></code></a>, in bytes.</p>
<p>If the size of the plaintext buffer is at least this large, it is guaranteed that <a class="reference internal" href="#c.psa_aead_decrypt" title="psa_aead_decrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_decrypt()</span></code></a> will not fail due to an insufficient buffer size. Depending on the algorithm, the actual size of the plaintext may be smaller.</p>
</div>
<div class="section" id="PSA_AEAD_UPDATE_OUTPUT_SIZE">
<span id="c.PSA_AEAD_UPDATE_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_UPDATE_OUTPUT_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_UPDATE_OUTPUT_SIZE(alg, input_length) \</span>
<span class="cp">    (PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? PSA_ROUND_UP_TO_MULTIPLE(PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE, (input_length)) : (input_length))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An AEAD algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">input_length</span></code></dt>
<dd>Size of the input in bytes.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>A sufficient output buffer size for the specified algorithm. If the AEAD algorithm is not recognized, return 0. An implementation may return either 0 or a correct size for an AEAD algorithm that it recognizes, but does not support.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>A sufficient output buffer size for <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a>.</p>
<p>If the size of the output buffer is at least this large, it is guaranteed that <a class="reference internal" href="#c.psa_aead_update" title="psa_aead_update"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_update()</span></code></a> will not fail due to an insufficient buffer size. The actual size of the output may be smaller in any given call.</p>
</div>
<div class="section" id="PSA_AEAD_FINISH_OUTPUT_SIZE">
<span id="c.PSA_AEAD_FINISH_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_FINISH_OUTPUT_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_FINISH_OUTPUT_SIZE(alg) \</span>
<span class="cp">    (PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE : 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An AEAD algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>A sufficient ciphertext buffer size for the specified algorithm. If the AEAD algorithm is not recognized, return 0. An implementation may return either 0 or a correct size for an AEAD algorithm that it recognizes, but does not support.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>A sufficient ciphertext buffer size for <a class="reference internal" href="#c.psa_aead_finish" title="psa_aead_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_finish()</span></code></a>.</p>
<p>If the size of the ciphertext buffer is at least this large, it is guaranteed that <a class="reference internal" href="#c.psa_aead_finish" title="psa_aead_finish"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_finish()</span></code></a> will not fail due to an insufficient ciphertext buffer size. The actual size of the output may be smaller in any given call.</p>
</div>
<div class="section" id="PSA_AEAD_VERIFY_OUTPUT_SIZE">
<span id="c.PSA_AEAD_VERIFY_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_VERIFY_OUTPUT_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_AEAD_VERIFY_OUTPUT_SIZE(alg) \</span>
<span class="cp">    (PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER(alg) ? PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE : 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>An AEAD algorithm (<code class="docutils literal notranslate"><span class="pre">PSA_ALG_XXX</span></code> value such that <a class="reference internal" href="#c.PSA_ALG_IS_AEAD" title="PSA_ALG_IS_AEAD"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code></a>(<code class="docutils literal notranslate"><span class="pre">alg</span></code>) is true).</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>A sufficient plaintext buffer size for the specified algorithm. If the AEAD algorithm is not recognized, return 0. An implementation may return either 0 or a correct size for an AEAD algorithm that it recognizes, but does not support.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>A sufficient plaintext buffer size for <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a>.</p>
<p>If the size of the plaintext buffer is at least this large, it is guaranteed that <a class="reference internal" href="#c.psa_aead_verify" title="psa_aead_verify"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_aead_verify()</span></code></a> will not fail due to an insufficient plaintext buffer size. The actual size of the output may be smaller in any given call.</p>
</div>
<div class="section" id="PSA_RSA_MINIMUM_PADDING_SIZE">
<span id="c.PSA_RSA_MINIMUM_PADDING_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_RSA_MINIMUM_PADDING_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_RSA_MINIMUM_PADDING_SIZE(alg) \</span>
<span class="cp">    (PSA_ALG_IS_RSA_OAEP(alg) ? 2 * PSA_HASH_SIZE(PSA_ALG_RSA_OAEP_GET_HASH(alg)) + 1 : 11 </span><span class="cm">/*PKCS#1v1.5*/</span><span class="cp">)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_ECDSA_SIGNATURE_SIZE">
<span id="c.PSA_ECDSA_SIGNATURE_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ECDSA_SIGNATURE_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ECDSA_SIGNATURE_SIZE(curve_bits) \</span>
<span class="cp">    (PSA_BITS_TO_BYTES(curve_bits) * 2)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">curve_bits</span></code></dt>
<dd>Curve size in bits.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>Signature size in bytes.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>ECDSA signature size for a given curve bit size.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">This macro returns a compile-time constant if its argument is one.</p>
</div>
</div>
<div class="section" id="PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE">
<span id="c.PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE(key_type, key_bits, alg) \</span>
<span class="cp">    (PSA_KEY_TYPE_IS_RSA(key_type) ? ((void)alg, PSA_BITS_TO_BYTES(key_bits)) : PSA_KEY_TYPE_IS_ECC(key_type) ? PSA_ECDSA_SIGNATURE_SIZE(key_bits) : ((void)alg, 0))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">key_type</span></code></dt>
<dd>An asymmetric key type (this may indifferently be a key pair type or a public key type).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt>
<dd>The size of the key in bits.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The signature algorithm.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>If the parameters are valid and supported, return a buffer size in bytes that guarantees that <a class="reference internal" href="#c.psa_asymmetric_sign" title="psa_asymmetric_sign"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_sign()</span></code></a> will not fail with <a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a>. If the parameters are a valid combination that is not supported by the implementation, this macro shall return either a sensible size or 0. If the parameters are not valid, the return value is unspecified.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Sufficient signature buffer size for <a class="reference internal" href="#c.psa_asymmetric_sign" title="psa_asymmetric_sign"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_sign()</span></code></a>.</p>
<p>This macro returns a sufficient buffer size for a signature using a key of the specified type and size, with the specified algorithm. Note that the actual size of the signature may be smaller (some algorithms produce a variable-size signature).</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">This function may call its arguments multiple times or zero times, so you should not pass arguments that contain side effects.</p>
</div>
</div>
<div class="section" id="PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE">
<span id="c.PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE(key_type, key_bits, alg) \</span>
<span class="cp">    (PSA_KEY_TYPE_IS_RSA(key_type) ? ((void)alg, PSA_BITS_TO_BYTES(key_bits)) : 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">key_type</span></code></dt>
<dd>An asymmetric key type (this may indifferently be a key pair type or a public key type).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt>
<dd>The size of the key in bits.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The signature algorithm.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>If the parameters are valid and supported, return a buffer size in bytes that guarantees that <a class="reference internal" href="#c.psa_asymmetric_encrypt" title="psa_asymmetric_encrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_encrypt()</span></code></a> will not fail with <a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a>. If the parameters are a valid combination that is not supported by the implementation, this macro shall return either a sensible size or 0. If the parameters are not valid, the return value is unspecified.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Sufficient output buffer size for <a class="reference internal" href="#c.psa_asymmetric_encrypt" title="psa_asymmetric_encrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_encrypt()</span></code></a>.</p>
<p>This macro returns a sufficient buffer size for a ciphertext produced using a key of the specified type and size, with the specified algorithm. Note that the actual size of the ciphertext may be smaller, depending on the algorithm.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">This function may call its arguments multiple times or zero times, so you should not pass arguments that contain side effects.</p>
</div>
</div>
<div class="section" id="PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE">
<span id="c.PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE(key_type, key_bits, alg) \</span>
<span class="cp">    (PSA_KEY_TYPE_IS_RSA(key_type) ? PSA_BITS_TO_BYTES(key_bits) - PSA_RSA_MINIMUM_PADDING_SIZE(alg) : 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">key_type</span></code></dt>
<dd>An asymmetric key type (this may indifferently be a key pair type or a public key type).</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt>
<dd>The size of the key in bits.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">alg</span></code></dt>
<dd>The signature algorithm.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>If the parameters are valid and supported, return a buffer size in bytes that guarantees that <a class="reference internal" href="#c.psa_asymmetric_decrypt" title="psa_asymmetric_decrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_decrypt()</span></code></a> will not fail with <a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a>. If the parameters are a valid combination that is not supported by the implementation, this macro shall return either a sensible size or 0. If the parameters are not valid, the return value is unspecified.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Sufficient output buffer size for <a class="reference internal" href="#c.psa_asymmetric_decrypt" title="psa_asymmetric_decrypt"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_decrypt()</span></code></a>.</p>
<p>This macro returns a sufficient buffer size for a ciphertext produced using a key of the specified type and size, with the specified algorithm. Note that the actual size of the ciphertext may be smaller, depending on the algorithm.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">This function may call its arguments multiple times or zero times, so you should not pass arguments that contain side effects.</p>
</div>
</div>
<div class="section" id="PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE">
<span id="c.PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE(bits)  ((bits) / 8 + 5)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">bits</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE">
<span id="c.PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(key_bits) \</span>
<span class="cp">    (PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE(key_bits) + 11)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE">
<span id="c.PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(key_bits) \</span>
<span class="cp">    (9 * PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE((key_bits) / 2 + 1) + 14)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE">
<span id="c.PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE(key_bits) \</span>
<span class="cp">    (PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE(key_bits) * 3 + 59)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE">
<span id="c.PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE(key_bits) \</span>
<span class="cp">    (PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE(key_bits) * 3 + 75)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE">
<span id="c.PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits) \</span>
<span class="cp">    (2 * PSA_BITS_TO_BYTES(key_bits) + 1)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE">
<span id="c.PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(key_bits) \</span>
<span class="cp">    (PSA_BITS_TO_BYTES(key_bits))</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt>
<dd></dd>
</dl>
<p class="subitem-title"><strong>Description:</strong></p>
</div>
<div class="section" id="PSA_KEY_EXPORT_MAX_SIZE">
<span id="c.PSA_KEY_EXPORT_MAX_SIZE"></span><h2><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_MAX_SIZE</span></code> (macro)</h2>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="cp">#define PSA_KEY_EXPORT_MAX_SIZE(key_type, key_bits) \</span>
<span class="cp">    (PSA_KEY_TYPE_IS_UNSTRUCTURED(key_type) ? PSA_BITS_TO_BYTES(key_bits) : (key_type) == PSA_KEY_TYPE_RSA_KEY_PAIR ? PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE(key_bits) : (key_type) == PSA_KEY_TYPE_RSA_PUBLIC_KEY ? PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE(key_bits) : (key_type) == PSA_KEY_TYPE_DSA_KEY_PAIR ? PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE(key_bits) : (key_type) == PSA_KEY_TYPE_DSA_PUBLIC_KEY ? PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE(key_bits) : PSA_KEY_TYPE_IS_ECC_KEY_PAIR(key_type) ? PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE(key_bits) : PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY(key_type) ? PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE(key_bits) : 0)</span>
</pre></div>
</div>
<p class="subitem-title"><strong>Parameters:</strong> </p>
<dl class="docutils">
<dt> <code class="docutils literal notranslate"><span class="pre">key_type</span></code></dt>
<dd>A supported key type.</dd>
<dt> <code class="docutils literal notranslate"><span class="pre">key_bits</span></code></dt>
<dd>The size of the key in bits.</dd>
</dl>
<p class="subitem-title"><strong>Returns:</strong> </p>
<p>If the parameters are valid and supported, return a buffer size in bytes that guarantees that <a class="reference internal" href="#c.psa_asymmetric_sign" title="psa_asymmetric_sign"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_asymmetric_sign()</span></code></a> will not fail with <a class="reference internal" href="#c.PSA_ERROR_BUFFER_TOO_SMALL" title="PSA_ERROR_BUFFER_TOO_SMALL"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code></a>. If the parameters are a valid combination that is not supported by the implementation, this macro shall return either a sensible size or 0. If the parameters are not valid, the return value is unspecified.</p>
<p class="subitem-title"><strong>Description:</strong></p>
<p>Sufficient output buffer size for <a class="reference internal" href="#c.psa_export_key" title="psa_export_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_key()</span></code></a> or <a class="reference internal" href="#c.psa_export_public_key" title="psa_export_public_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_public_key()</span></code></a>.</p>
<p>This macro returns a compile-time constant if its arguments are compile-time constants.</p>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">This function may call its arguments multiple times or zero times, so you should not pass arguments that contain side effects.</p>
</div>
<p>The following code illustrates how to allocate enough memory to export a key by querying the key type and size at runtime.</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_attributes_t</span> <span class="n">attributes</span> <span class="o">=</span> <span class="n">PSA_KEY_ATTRIBUTES_INIT</span><span class="p">;</span>
<span class="n">psa_status_t</span> <span class="n">status</span><span class="p">;</span>
<span class="n">status</span> <span class="o">=</span> <span class="n">psa_get_key_attributes</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">attributes</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">status</span> <span class="o">!=</span> <span class="n">PSA_SUCCESS</span><span class="p">)</span> <span class="n">handle_error</span><span class="p">(...);</span>
<span class="n">psa_key_type_t</span> <span class="n">key_type</span> <span class="o">=</span> <span class="n">psa_get_key_type</span><span class="p">(</span><span class="o">&amp;</span><span class="n">attributes</span><span class="p">);</span>
<span class="kt">size_t</span> <span class="n">key_bits</span> <span class="o">=</span> <span class="n">psa_get_key_bits</span><span class="p">(</span><span class="o">&amp;</span><span class="n">attributes</span><span class="p">);</span>
<span class="kt">size_t</span> <span class="n">buffer_size</span> <span class="o">=</span> <span class="n">PSA_KEY_EXPORT_MAX_SIZE</span><span class="p">(</span><span class="n">key_type</span><span class="p">,</span> <span class="n">key_bits</span><span class="p">);</span>
<span class="n">psa_reset_key_attributes</span><span class="p">(</span><span class="o">&amp;</span><span class="n">attributes</span><span class="p">);</span>
<span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span><span class="n">buffer</span> <span class="o">=</span> <span class="n">malloc</span><span class="p">(</span><span class="n">buffer_size</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">buffer</span> <span class="o">==</span> <span class="nb">NULL</span><span class="p">)</span> <span class="n">handle_error</span><span class="p">(...);</span>
<span class="kt">size_t</span> <span class="n">buffer_length</span><span class="p">;</span>
<span class="n">status</span> <span class="o">=</span> <span class="n">psa_export_key</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">buffer</span><span class="p">,</span> <span class="n">buffer_size</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">buffer_length</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">status</span> <span class="o">!=</span> <span class="n">PSA_SUCCESS</span><span class="p">)</span> <span class="n">handle_error</span><span class="p">(...);</span>
</pre></div>
</div>
<p>For <a class="reference internal" href="#c.psa_export_public_key" title="psa_export_public_key"><code class="xref any c c-func docutils literal notranslate"><span class="pre">psa_export_public_key()</span></code></a>, calculate the buffer size from the public key type. You can use the macro <a class="reference internal" href="#c.PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR" title="PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR"><code class="xref any c c-macro docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR</span></code></a> to convert a key pair type to the corresponding public key type.</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">psa_key_attributes_t</span> <span class="n">attributes</span> <span class="o">=</span> <span class="n">PSA_KEY_ATTRIBUTES_INIT</span><span class="p">;</span>
<span class="n">psa_status_t</span> <span class="n">status</span><span class="p">;</span>
<span class="n">status</span> <span class="o">=</span> <span class="n">psa_get_key_attributes</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">attributes</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">status</span> <span class="o">!=</span> <span class="n">PSA_SUCCESS</span><span class="p">)</span> <span class="n">handle_error</span><span class="p">(...);</span>
<span class="n">psa_key_type_t</span> <span class="n">key_type</span> <span class="o">=</span> <span class="n">psa_get_key_type</span><span class="p">(</span><span class="o">&amp;</span><span class="n">attributes</span><span class="p">);</span>
<span class="n">psa_key_type_t</span> <span class="n">public_key_type</span> <span class="o">=</span> <span class="n">PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR</span><span class="p">(</span><span class="n">key_type</span><span class="p">);</span>
<span class="kt">size_t</span> <span class="n">key_bits</span> <span class="o">=</span> <span class="n">psa_get_key_bits</span><span class="p">(</span><span class="o">&amp;</span><span class="n">attributes</span><span class="p">);</span>
<span class="kt">size_t</span> <span class="n">buffer_size</span> <span class="o">=</span> <span class="n">PSA_KEY_EXPORT_MAX_SIZE</span><span class="p">(</span><span class="n">public_key_type</span><span class="p">,</span> <span class="n">key_bits</span><span class="p">);</span>
<span class="n">psa_reset_key_attributes</span><span class="p">(</span><span class="o">&amp;</span><span class="n">attributes</span><span class="p">);</span>
<span class="kt">unsigned</span> <span class="kt">char</span> <span class="o">*</span><span class="n">buffer</span> <span class="o">=</span> <span class="n">malloc</span><span class="p">(</span><span class="n">buffer_size</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">buffer</span> <span class="o">==</span> <span class="nb">NULL</span><span class="p">)</span> <span class="n">handle_error</span><span class="p">(...);</span>
<span class="kt">size_t</span> <span class="n">buffer_length</span><span class="p">;</span>
<span class="n">status</span> <span class="o">=</span> <span class="n">psa_export_public_key</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">buffer</span><span class="p">,</span> <span class="n">buffer_size</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">buffer_length</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">status</span> <span class="o">!=</span> <span class="n">PSA_SUCCESS</span><span class="p">)</span> <span class="n">handle_error</span><span class="p">(...);</span>
</pre></div>
</div>
</div>
</div>


          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="index.html">psa_crypto_api</a></h1>








<h3>Navigation</h3>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="general.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="general.html#design-goals">Design goals</a></li>
<li class="toctree-l1"><a class="reference internal" href="general.html#functionality-overview">Functionality overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="general.html#sample-architectures">Sample architectures</a></li>
<li class="toctree-l1"><a class="reference internal" href="general.html#library-conventions">Library conventions</a></li>
<li class="toctree-l1"><a class="reference internal" href="general.html#implementation-considerations">Implementation considerations</a></li>
<li class="toctree-l1"><a class="reference internal" href="general.html#usage-considerations">Usage considerations</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Implementation-specific definitions</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_handle_t"><code class="docutils literal notranslate"><span class="pre">psa_key_handle_t</span></code> (type)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#library-initialization">Library initialization</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_crypto_init"><code class="docutils literal notranslate"><span class="pre">psa_crypto_init</span></code> (function)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#key-attributes">Key attributes</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_attributes_t"><code class="docutils literal notranslate"><span class="pre">psa_key_attributes_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_ATTRIBUTES_INIT"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ATTRIBUTES_INIT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_attributes_init"><code class="docutils literal notranslate"><span class="pre">psa_key_attributes_init</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_set_key_id"><code class="docutils literal notranslate"><span class="pre">psa_set_key_id</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_set_key_lifetime"><code class="docutils literal notranslate"><span class="pre">psa_set_key_lifetime</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_get_key_id"><code class="docutils literal notranslate"><span class="pre">psa_get_key_id</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_get_key_lifetime"><code class="docutils literal notranslate"><span class="pre">psa_get_key_lifetime</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_set_key_usage_flags"><code class="docutils literal notranslate"><span class="pre">psa_set_key_usage_flags</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_get_key_usage_flags"><code class="docutils literal notranslate"><span class="pre">psa_get_key_usage_flags</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_set_key_algorithm"><code class="docutils literal notranslate"><span class="pre">psa_set_key_algorithm</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_get_key_algorithm"><code class="docutils literal notranslate"><span class="pre">psa_get_key_algorithm</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_set_key_type"><code class="docutils literal notranslate"><span class="pre">psa_set_key_type</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_set_key_bits"><code class="docutils literal notranslate"><span class="pre">psa_set_key_bits</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_get_key_type"><code class="docutils literal notranslate"><span class="pre">psa_get_key_type</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_get_key_bits"><code class="docutils literal notranslate"><span class="pre">psa_get_key_bits</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_get_key_attributes"><code class="docutils literal notranslate"><span class="pre">psa_get_key_attributes</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_reset_key_attributes"><code class="docutils literal notranslate"><span class="pre">psa_reset_key_attributes</span></code> (function)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#key-management">Key management</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_open_key"><code class="docutils literal notranslate"><span class="pre">psa_open_key</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_close_key"><code class="docutils literal notranslate"><span class="pre">psa_close_key</span></code> (function)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#key-import-and-export">Key import and export</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_import_key"><code class="docutils literal notranslate"><span class="pre">psa_import_key</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_destroy_key"><code class="docutils literal notranslate"><span class="pre">psa_destroy_key</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_export_key"><code class="docutils literal notranslate"><span class="pre">psa_export_key</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_export_public_key"><code class="docutils literal notranslate"><span class="pre">psa_export_public_key</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_copy_key"><code class="docutils literal notranslate"><span class="pre">psa_copy_key</span></code> (function)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#message-digests">Message digests</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_hash_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_hash_operation_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_HASH_OPERATION_INIT"><code class="docutils literal notranslate"><span class="pre">PSA_HASH_OPERATION_INIT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_hash_compute"><code class="docutils literal notranslate"><span class="pre">psa_hash_compute</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_hash_compare"><code class="docutils literal notranslate"><span class="pre">psa_hash_compare</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_hash_operation_init"><code class="docutils literal notranslate"><span class="pre">psa_hash_operation_init</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_hash_setup"><code class="docutils literal notranslate"><span class="pre">psa_hash_setup</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_hash_update"><code class="docutils literal notranslate"><span class="pre">psa_hash_update</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_hash_finish"><code class="docutils literal notranslate"><span class="pre">psa_hash_finish</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_hash_verify"><code class="docutils literal notranslate"><span class="pre">psa_hash_verify</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_hash_abort"><code class="docutils literal notranslate"><span class="pre">psa_hash_abort</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_hash_clone"><code class="docutils literal notranslate"><span class="pre">psa_hash_clone</span></code> (function)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#message-authentication-codes">Message authentication codes</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_mac_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_mac_operation_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_MAC_OPERATION_INIT"><code class="docutils literal notranslate"><span class="pre">PSA_MAC_OPERATION_INIT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_mac_compute"><code class="docutils literal notranslate"><span class="pre">psa_mac_compute</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_mac_verify"><code class="docutils literal notranslate"><span class="pre">psa_mac_verify</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_mac_operation_init"><code class="docutils literal notranslate"><span class="pre">psa_mac_operation_init</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_mac_sign_setup"><code class="docutils literal notranslate"><span class="pre">psa_mac_sign_setup</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_mac_verify_setup"><code class="docutils literal notranslate"><span class="pre">psa_mac_verify_setup</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_mac_update"><code class="docutils literal notranslate"><span class="pre">psa_mac_update</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_mac_sign_finish"><code class="docutils literal notranslate"><span class="pre">psa_mac_sign_finish</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_mac_verify_finish"><code class="docutils literal notranslate"><span class="pre">psa_mac_verify_finish</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_mac_abort"><code class="docutils literal notranslate"><span class="pre">psa_mac_abort</span></code> (function)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#symmetric-ciphers">Symmetric ciphers</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_cipher_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_cipher_operation_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_CIPHER_OPERATION_INIT"><code class="docutils literal notranslate"><span class="pre">PSA_CIPHER_OPERATION_INIT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_cipher_encrypt"><code class="docutils literal notranslate"><span class="pre">psa_cipher_encrypt</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_cipher_decrypt"><code class="docutils literal notranslate"><span class="pre">psa_cipher_decrypt</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_cipher_operation_init"><code class="docutils literal notranslate"><span class="pre">psa_cipher_operation_init</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_cipher_encrypt_setup"><code class="docutils literal notranslate"><span class="pre">psa_cipher_encrypt_setup</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_cipher_decrypt_setup"><code class="docutils literal notranslate"><span class="pre">psa_cipher_decrypt_setup</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_cipher_generate_iv"><code class="docutils literal notranslate"><span class="pre">psa_cipher_generate_iv</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_cipher_set_iv"><code class="docutils literal notranslate"><span class="pre">psa_cipher_set_iv</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_cipher_update"><code class="docutils literal notranslate"><span class="pre">psa_cipher_update</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_cipher_finish"><code class="docutils literal notranslate"><span class="pre">psa_cipher_finish</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_cipher_abort"><code class="docutils literal notranslate"><span class="pre">psa_cipher_abort</span></code> (function)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#authenticated-encryption-with-associated-data-aead">Authenticated encryption with associated data (AEAD)</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_aead_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_aead_operation_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_OPERATION_INIT"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_OPERATION_INIT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_aead_encrypt"><code class="docutils literal notranslate"><span class="pre">psa_aead_encrypt</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_aead_decrypt"><code class="docutils literal notranslate"><span class="pre">psa_aead_decrypt</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_aead_operation_init"><code class="docutils literal notranslate"><span class="pre">psa_aead_operation_init</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_aead_encrypt_setup"><code class="docutils literal notranslate"><span class="pre">psa_aead_encrypt_setup</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_aead_decrypt_setup"><code class="docutils literal notranslate"><span class="pre">psa_aead_decrypt_setup</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_aead_generate_nonce"><code class="docutils literal notranslate"><span class="pre">psa_aead_generate_nonce</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_aead_set_nonce"><code class="docutils literal notranslate"><span class="pre">psa_aead_set_nonce</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_aead_set_lengths"><code class="docutils literal notranslate"><span class="pre">psa_aead_set_lengths</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_aead_update_ad"><code class="docutils literal notranslate"><span class="pre">psa_aead_update_ad</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_aead_update"><code class="docutils literal notranslate"><span class="pre">psa_aead_update</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_aead_finish"><code class="docutils literal notranslate"><span class="pre">psa_aead_finish</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_aead_verify"><code class="docutils literal notranslate"><span class="pre">psa_aead_verify</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_aead_abort"><code class="docutils literal notranslate"><span class="pre">psa_aead_abort</span></code> (function)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#asymmetric-cryptography">Asymmetric cryptography</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_asymmetric_sign"><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_sign</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_asymmetric_verify"><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_verify</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_asymmetric_encrypt"><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_encrypt</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_asymmetric_decrypt"><code class="docutils literal notranslate"><span class="pre">psa_asymmetric_decrypt</span></code> (function)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#key-derivation-and-pseudorandom-generation">Key derivation and pseudorandom generation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_operation_t"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_operation_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_DERIVATION_OPERATION_INIT"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_OPERATION_INIT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_DERIVATION_UNLIMITED_CAPACITY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_UNLIMITED_CAPACITY</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_operation_init"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_operation_init</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_setup"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_setup</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_get_capacity"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_get_capacity</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_set_capacity"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_set_capacity</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_input_bytes"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_input_bytes</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_input_key"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_input_key</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_key_agreement"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_key_agreement</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_output_bytes"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_output_bytes</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_output_key"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_output_key</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_abort"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_abort</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_raw_key_agreement"><code class="docutils literal notranslate"><span class="pre">psa_raw_key_agreement</span></code> (function)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#random-generation">Random generation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_generate_random"><code class="docutils literal notranslate"><span class="pre">psa_generate_random</span></code> (function)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_generate_key"><code class="docutils literal notranslate"><span class="pre">psa_generate_key</span></code> (function)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#error-codes">Error codes</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_status_t"><code class="docutils literal notranslate"><span class="pre">psa_status_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_SUCCESS"><code class="docutils literal notranslate"><span class="pre">PSA_SUCCESS</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_GENERIC_ERROR"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_GENERIC_ERROR</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_NOT_SUPPORTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_SUPPORTED</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_NOT_PERMITTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_NOT_PERMITTED</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_BUFFER_TOO_SMALL"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BUFFER_TOO_SMALL</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_ALREADY_EXISTS"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_ALREADY_EXISTS</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_DOES_NOT_EXIST"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_DOES_NOT_EXIST</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_BAD_STATE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_BAD_STATE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INVALID_ARGUMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_ARGUMENT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INSUFFICIENT_MEMORY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_MEMORY</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INSUFFICIENT_STORAGE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_STORAGE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_COMMUNICATION_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_COMMUNICATION_FAILURE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_STORAGE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_STORAGE_FAILURE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_HARDWARE_FAILURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_HARDWARE_FAILURE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_CORRUPTION_DETECTED"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_CORRUPTION_DETECTED</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INSUFFICIENT_ENTROPY"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_ENTROPY</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INVALID_SIGNATURE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_SIGNATURE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INVALID_PADDING"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_PADDING</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INSUFFICIENT_DATA"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INSUFFICIENT_DATA</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ERROR_INVALID_HANDLE"><code class="docutils literal notranslate"><span class="pre">PSA_ERROR_INVALID_HANDLE</span></code> (macro)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#key-and-algorithm-types">Key and algorithm types</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_type_t"><code class="docutils literal notranslate"><span class="pre">psa_key_type_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_ecc_curve_t"><code class="docutils literal notranslate"><span class="pre">psa_ecc_curve_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_dh_group_t"><code class="docutils literal notranslate"><span class="pre">psa_dh_group_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_algorithm_t"><code class="docutils literal notranslate"><span class="pre">psa_algorithm_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_NONE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_NONE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_VENDOR_FLAG"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_VENDOR_FLAG</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CATEGORY_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_MASK</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CATEGORY_SYMMETRIC"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_SYMMETRIC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CATEGORY_RAW"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_RAW</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_PUBLIC_KEY</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CATEGORY_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_KEY_PAIR</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CATEGORY_FLAG_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CATEGORY_FLAG_PAIR</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_VENDOR_DEFINED"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_VENDOR_DEFINED</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_UNSTRUCTURED"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_UNSTRUCTURED</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_ASYMMETRIC"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ASYMMETRIC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_PUBLIC_KEY</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_KEY_PAIR</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_KEY_PAIR_OF_PUBLIC_KEY</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_PUBLIC_KEY_OF_KEY_PAIR</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_RAW_DATA"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RAW_DATA</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_HMAC"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_HMAC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_DERIVE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DERIVE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_AES"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_AES</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_DES"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DES</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CAMELLIA"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CAMELLIA</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_ARC4"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ARC4</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_CHACHA20"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_CHACHA20</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_RSA_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_PUBLIC_KEY</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_RSA_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_RSA_KEY_PAIR</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_RSA"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_RSA</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_PUBLIC_KEY_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_ECC_KEY_PAIR_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_ECC_CURVE_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_CURVE_MASK</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_ECC_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_KEY_PAIR</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_ECC_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_ECC_PUBLIC_KEY</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_ECC"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_ECC_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC_KEY_PAIR</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_ECC_PUBLIC_KEY</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_GET_CURVE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_GET_CURVE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT163K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT163K1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT163R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT163R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT163R2"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT163R2</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT193R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT193R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT193R2"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT193R2</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT233K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT233K1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT233R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT233R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT239K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT239K1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT283K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT283K1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT283R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT283R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT409K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT409K1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT409R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT409R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT571K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT571K1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECT571R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECT571R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP160K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP160K1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP160R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP160R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP160R2"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP160R2</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP192K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP192K1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP192R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP192R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP224K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP224K1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP224R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP224R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP256K1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP256K1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP256R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP256R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP384R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP384R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_SECP521R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_SECP521R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_BRAINPOOL_P256R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_P256R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_BRAINPOOL_P384R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_P384R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_BRAINPOOL_P512R1"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BRAINPOOL_P512R1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_CURVE25519"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVE25519</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_CURVE448"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_CURVE448</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_PUBLIC_KEY_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_DH_KEY_PAIR_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_KEY_PAIR_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_DH_GROUP_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_GROUP_MASK</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_DH_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_KEY_PAIR</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_DH_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_DH_PUBLIC_KEY</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_DH"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_DH_KEY_PAIR"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH_KEY_PAIR</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_IS_DH_PUBLIC_KEY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_IS_DH_PUBLIC_KEY</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_TYPE_GET_GROUP"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_TYPE_GET_GROUP</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_DH_GROUP_FFDHE2048"><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE2048</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_DH_GROUP_FFDHE3072"><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE3072</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_DH_GROUP_FFDHE4096"><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE4096</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_DH_GROUP_FFDHE6144"><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE6144</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_DH_GROUP_FFDHE8192"><code class="docutils literal notranslate"><span class="pre">PSA_DH_GROUP_FFDHE8192</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_BLOCK_CIPHER_BLOCK_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_BLOCK_CIPHER_BLOCK_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_VENDOR_FLAG"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_VENDOR_FLAG</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_MASK</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_HASH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_MAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_MAC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_CIPHER"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_CIPHER</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_AEAD"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_AEAD</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_SIGN"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_SIGN</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_ASYMMETRIC_ENCRYPTION</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_KEY_DERIVATION"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_KEY_DERIVATION</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CATEGORY_KEY_AGREEMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CATEGORY_KEY_AGREEMENT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_VENDOR_DEFINED"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_VENDOR_DEFINED</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_MAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_MAC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_CIPHER"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_CIPHER</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_AEAD"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_SIGN"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_SIGN</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_ASYMMETRIC_ENCRYPTION"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_ASYMMETRIC_ENCRYPTION</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_KEY_AGREEMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_AGREEMENT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_KEY_DERIVATION"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_DERIVATION</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_HASH_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HASH_MASK</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_MD2"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MD2</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_MD4"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MD4</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_MD5"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MD5</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RIPEMD160"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RIPEMD160</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA_1"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_1</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA_224"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_224</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA_256"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_256</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA_384"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_384</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA_512"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_512</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA_512_224"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_512_224</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA_512_256"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA_512_256</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA3_224"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_224</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA3_256"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_256</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA3_384"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_384</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SHA3_512"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SHA3_512</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_ANY_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ANY_HASH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_MAC_SUBCATEGORY_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MAC_SUBCATEGORY_MASK</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_HMAC_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HMAC_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_HMAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HMAC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_HMAC_GET_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HMAC_GET_HASH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_HMAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HMAC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_MAC_TRUNCATION_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_MAC_TRUNCATION_MASK</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_MAC_TRUNCATION_OFFSET"><code class="docutils literal notranslate"><span class="pre">PSA_MAC_TRUNCATION_OFFSET</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TRUNCATED_MAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TRUNCATED_MAC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_FULL_LENGTH_MAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_FULL_LENGTH_MAC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_MAC_TRUNCATED_LENGTH"><code class="docutils literal notranslate"><span class="pre">PSA_MAC_TRUNCATED_LENGTH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CIPHER_MAC_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CIPHER_MAC_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CBC_MAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CBC_MAC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CMAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CMAC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_GMAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_GMAC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_BLOCK_CIPHER_MAC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_BLOCK_CIPHER_MAC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CIPHER_STREAM_FLAG"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CIPHER_STREAM_FLAG</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CIPHER_FROM_BLOCK_FLAG"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CIPHER_FROM_BLOCK_FLAG</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_STREAM_CIPHER"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_STREAM_CIPHER</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_ARC4"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ARC4</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CHACHA20"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CHACHA20</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CTR"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CTR</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CFB"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CFB</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_OFB"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_OFB</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_XTS"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_XTS</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CBC_NO_PADDING"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CBC_NO_PADDING</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CBC_PKCS7"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CBC_PKCS7</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_AEAD_FROM_BLOCK_FLAG"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_FROM_BLOCK_FLAG</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_AEAD_ON_BLOCK_CIPHER</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CCM"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CCM</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_GCM"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_GCM</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_CHACHA20_POLY1305"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_CHACHA20_POLY1305</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_AEAD_TAG_LENGTH_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_TAG_LENGTH_MASK</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_TAG_LENGTH_OFFSET"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_TAG_LENGTH_OFFSET</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_AEAD_WITH_TAG_LENGTH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_WITH_TAG_LENGTH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_AEAD_WITH_DEFAULT_TAG_LENGTH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE"><code class="docutils literal notranslate"><span class="pre">PSA__ALG_AEAD_WITH_DEFAULT_TAG_LENGTH__CASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_PKCS1V15_SIGN_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_PKCS1V15_SIGN"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_PKCS1V15_SIGN_RAW"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_SIGN_RAW</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_RSA_PKCS1V15_SIGN"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RSA_PKCS1V15_SIGN</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_PSS_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PSS_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_PSS"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PSS</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_RSA_PSS"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RSA_PSS</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_ECDSA_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_ECDSA"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_ECDSA_ANY"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA_ANY</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_DETERMINISTIC_ECDSA_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_DETERMINISTIC_ECDSA_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_DETERMINISTIC_ECDSA"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_DETERMINISTIC_ECDSA</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_ECDSA"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_ECDSA</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_ECDSA_IS_DETERMINISTIC"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDSA_IS_DETERMINISTIC</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_DETERMINISTIC_ECDSA"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_DETERMINISTIC_ECDSA</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_RANDOMIZED_ECDSA"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RANDOMIZED_ECDSA</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_HASH_AND_SIGN"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HASH_AND_SIGN</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_SIGN_GET_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_SIGN_GET_HASH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_PKCS1V15_CRYPT"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_PKCS1V15_CRYPT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_OAEP_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_OAEP_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_OAEP"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_OAEP</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_RSA_OAEP"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RSA_OAEP</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_RSA_OAEP_GET_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_RSA_OAEP_GET_HASH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_HKDF_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HKDF_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_HKDF"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HKDF</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_HKDF"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_HKDF</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_HKDF_GET_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_HKDF_GET_HASH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TLS12_PRF_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PRF_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TLS12_PRF"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PRF</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_TLS12_PRF"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_TLS12_PRF</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TLS12_PRF_GET_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PRF_GET_HASH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TLS12_PSK_TO_MS_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TLS12_PSK_TO_MS"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_TLS12_PSK_TO_MS"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_TLS12_PSK_TO_MS</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TLS12_PSK_TO_MS_GET_HASH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS_GET_HASH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_KEY_DERIVATION_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_DERIVATION_MASK</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_KEY_AGREEMENT_MASK"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT_MASK</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_KEY_AGREEMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_KEY_AGREEMENT_GET_KDF"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT_GET_KDF</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_KEY_AGREEMENT_GET_BASE"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_KEY_AGREEMENT_GET_BASE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_RAW_KEY_AGREEMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_RAW_KEY_AGREEMENT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_KEY_DERIVATION_OR_AGREEMENT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_FFDH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_FFDH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_FFDH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_FFDH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_ECDH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_ECDH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_ECDH"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_ECDH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_IS_WILDCARD"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_IS_WILDCARD</span></code> (macro)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#key-lifetimes">Key lifetimes</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_lifetime_t"><code class="docutils literal notranslate"><span class="pre">psa_key_lifetime_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_id_t"><code class="docutils literal notranslate"><span class="pre">psa_key_id_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_LIFETIME_VOLATILE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_VOLATILE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_LIFETIME_PERSISTENT"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_LIFETIME_PERSISTENT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_ID_USER_MIN"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_USER_MIN</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_ID_USER_MAX"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_USER_MAX</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_ID_VENDOR_MIN"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MIN</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_ID_VENDOR_MAX"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_ID_VENDOR_MAX</span></code> (macro)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#key-policies">Key policies</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_usage_t"><code class="docutils literal notranslate"><span class="pre">psa_key_usage_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_USAGE_EXPORT"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_EXPORT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_USAGE_COPY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_COPY</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_USAGE_ENCRYPT"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_ENCRYPT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_USAGE_DECRYPT"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_DECRYPT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_USAGE_SIGN"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_SIGN</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_USAGE_VERIFY"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_VERIFY</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_USAGE_DERIVE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_USAGE_DERIVE</span></code> (macro)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#key-derivation">Key derivation</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#psa_key_derivation_step_t"><code class="docutils literal notranslate"><span class="pre">psa_key_derivation_step_t</span></code> (type)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_DERIVATION_INPUT_SECRET"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SECRET</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_DERIVATION_INPUT_LABEL"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_LABEL</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_DERIVATION_INPUT_SALT"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SALT</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_DERIVATION_INPUT_INFO"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_INFO</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_DERIVATION_INPUT_SEED"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_DERIVATION_INPUT_SEED</span></code> (macro)</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="#other-definitions">Other definitions</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#PSA_BITS_TO_BYTES"><code class="docutils literal notranslate"><span class="pre">PSA_BITS_TO_BYTES</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_BYTES_TO_BITS"><code class="docutils literal notranslate"><span class="pre">PSA_BYTES_TO_BITS</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ROUND_UP_TO_MULTIPLE"><code class="docutils literal notranslate"><span class="pre">PSA_ROUND_UP_TO_MULTIPLE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_HASH_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_HASH_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_HASH_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_HASH_MAX_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_HMAC_MAX_HASH_BLOCK_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_HMAC_MAX_HASH_BLOCK_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_MAC_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_MAC_MAX_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_TAG_LENGTH"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_TAG_LENGTH</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_VENDOR_RSA_MAX_KEY_BITS"><code class="docutils literal notranslate"><span class="pre">PSA_VENDOR_RSA_MAX_KEY_BITS</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_VENDOR_ECC_MAX_CURVE_BITS"><code class="docutils literal notranslate"><span class="pre">PSA_VENDOR_ECC_MAX_CURVE_BITS</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECC_CURVE_BITS"><code class="docutils literal notranslate"><span class="pre">PSA_ECC_CURVE_BITS</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN"><code class="docutils literal notranslate"><span class="pre">PSA_ALG_TLS12_PSK_TO_MS_MAX_PSK_LEN</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_SIGNATURE_MAX_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_MAX_BLOCK_CIPHER_BLOCK_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_MAC_FINAL_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_MAC_FINAL_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_ENCRYPT_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_ENCRYPT_OUTPUT_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_DECRYPT_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_DECRYPT_OUTPUT_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_UPDATE_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_UPDATE_OUTPUT_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_FINISH_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_FINISH_OUTPUT_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_AEAD_VERIFY_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_AEAD_VERIFY_OUTPUT_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_RSA_MINIMUM_PADDING_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_RSA_MINIMUM_PADDING_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ECDSA_SIGNATURE_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_ECDSA_SIGNATURE_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_SIGN_OUTPUT_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_ENCRYPT_OUTPUT_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_ASYMMETRIC_DECRYPT_OUTPUT_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_ASN1_INTEGER_MAX_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_RSA_PUBLIC_KEY_MAX_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_RSA_KEY_PAIR_MAX_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_DSA_PUBLIC_KEY_MAX_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_DSA_KEY_PAIR_MAX_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_ECC_PUBLIC_KEY_MAX_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_ECC_KEY_PAIR_MAX_SIZE</span></code> (macro)</a></li>
<li class="toctree-l2"><a class="reference internal" href="#PSA_KEY_EXPORT_MAX_SIZE"><code class="docutils literal notranslate"><span class="pre">PSA_KEY_EXPORT_MAX_SIZE</span></code> (macro)</a></li>
</ul>
</li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="index.html">Documentation overview</a><ul>
      <li>Previous: <a href="general.html" title="previous chapter">Introduction</a></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2019, Arm.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 1.8.5</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
      
      |
      <a href="_sources/from_doxygen.rst.txt"
          rel="nofollow">Page source</a>
    </div>

    

    
  </body>
</html>